Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the title of an UIPopOver View Programmatically

How do you set the title of an UIPopOver View programmatically?

I found some sample code but wasn't able to set the title.

myView *theView = [[myView alloc] initWithNibName:@"myView" 
                                       bundle:nil];
UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:theView];
[aPopover setDelegate:self];
[aPopover setPopoverContentSize:CGSizeMake(320, 320) animated:YES];

[theView setPopover:aPopover];
[theView release];

[self.popoverController presentPopoverFromRect:CGRectMake(510,370,0,0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
like image 899
Yazzmi Avatar asked Jul 21 '10 06:07

Yazzmi


1 Answers

You need to wrap the view controller in a UINavigationCotnroller which will add a navigation bar with the appropriate title for the view controller. Something like this:

UINavigationController *container =
    [[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];

Then just initialize your popover to use container instead and present it as usual.

like image 66
Mike Weller Avatar answered Sep 17 '22 01:09

Mike Weller