Search code examples
ipadxamarin.iosuipopovercontroller

iPad UIPopoverController How to Set the Title


I have a UIPopoverController which displays a table. I use the PresentFromBarButtonItem method.

How can I give the pop up a title to display, much list the UISpliter does?


Solution

  • 1. Set title parameter of your UITableViewController;

    2. Add your UITableViewController to an UINavigationController.

    @interface YourTableViewController : UITableViewController < ... >
    ...
    @end
    

    ...

    ...

    YourTableViewController *vc = [[YourTableViewController alloc] init...  ;
    vc.title = @"Some Title";
    
    // add vc to an UINavigationController then forget it.
    UINavigationController *nav = [[UINavigationController alloc]
                                    initWithRootViewController:vc];
    [vc release];
    
    UIPopoverController *some_pvc = [[UIPopoverController alloc]
                                      initWithContentViewController:nav];
    [nav release];
    

    Then show the UIPopoverController some_pvc by sending presentPopoverFromRect: ... message to an UIViewController you will see the title bar

    alt text