Prateek Chaubey
Prateek Chaubey

Reputation: 645

Adding stuff to the UIPopoverController

I have made one popover. Presently that popover is blank. I need to add 6 buttons to the popover. Pressing any of the 6 buttons, the app takes the user to the respective screen. I want to add those buttons in table view style. You can consider the image attached with it (check the popup with 6 options in the left side of the iPad). I want to do it in the same way. Guide me please. Regards PC.enter image description here

Upvotes: 1

Views: 653

Answers (2)

djromero
djromero

Reputation: 19641

Open the Xcode Organizer > Documentation and search UIPopoverController. In the left sidebar, at the bottom, open 'Popovers' sample code project.

Basically you'll see that you need to create a UIPopoverController instance somewhere in your code:

- (void)viewDidLoad {
    ...
    /* 'contentCtrl' is an instance of UIViewController 
     * such as an UITableViewController
     */
    ...
    popover = [[UIPopoverController alloc] initWithContentViewController:contentCtrl];
    popover.popoverContentSize = CGSizeMake(320, 480);
    ...
}

And show it at some point, such as when the user press a button:

- (IBAction)showPopover:(id)sender {
    UIButton *button = (UIButton *)sender;
    [popover presentPopoverFromRect:button.frame 
                             inView:self.view 
           permittedArrowDirections:UIPopoverArrowDirectionAny 
                           animated:YES];
}

I'd suggest to study the sample. If you need help with the UITableView part, there are dozens of samples on the subject in the Documentation (and hundredths of questions in SO).

Upvotes: 2

logancautrell
logancautrell

Reputation: 8772

Create a view controller, add a UITableView, implement it to show the cells correctly, make it the content of the popover controller.

Upvotes: 2

Related Questions