Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Popover in ipad? [closed]

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.

like image 505
kernel.roy Avatar asked Aug 04 '11 10:08

kernel.roy


People also ask

What is a popover ios?

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.

What is a popover window?

A popover is a transient view that appears above other content onscreen when people click or tap a control or interactive area.

How do I present Viewcontroller in popover Swift?

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.


2 Answers

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);
like image 51
Prerna Avatar answered Sep 29 '22 21:09

Prerna


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.

like image 30
omz Avatar answered Sep 29 '22 19:09

omz