I want to develop a popover in my iPad application. A UIButton trigger will call the popover and that popover will contain a UITableViewController.
First I need a popover.
Need some example code or direction or link.
Thanks in advance.
A popover is a transient view that appears above other content onscreen when you tap a control or in an area. Typically, a popover includes an arrow pointing to the location from which it emerged.
A popover is a transient view that appears above other content onscreen when people click or tap a control or interactive area.
In the Bar Button Item section Change the System Item to Action. Next, Drag a new View Controller from the Object Library on to the Storyboard. Drag a Text View from the Object Library at the top of this View Controller. This View Controller will be displayed in the popover.
in your viewcontroller on the button action write this code:
- (IBAction)openAllRhymes:(id)sender{
UIButton *button = (UIButton*)sender;
PopupTableView *tableViewController = [[PopupTableView alloc] initWithStyle:UITableViewStylePlain];
popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
[popover presentPopoverFromRect:CGRectMake(button.frame.size.width / 2, button.frame.size.height / 1, 1, 1) inView:button permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[tableViewController release];
}
Now you have created a tableview for popover in that tableviewcontroller write:
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(108,400);
Read the documentation, it's all in there. If you don't understand it, start with general tutorials on iOS development or ask specifically about the parts you don't understand. You will need a solid understanding of how view controllers work before it makes sense to work with popovers. The View Controller Programming Guide also has a section specifically about popovers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With