I'm trying to display a UINavigationController
inside a UIPopoverController
, but for some reason I can't set the title.
SearchViewController *searchView = [[[SearchViewController alloc] init] autorelease];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:searchView];
[popover presentPopoverFromBarButtonItem:_searchBarButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
I tried changing it in the - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Change the title
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = @"Print / Email";
[label sizeToFit];
self.navigationItem.titleView = label;
}
return self;
}
I also tried setting it in the - (void)viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
self.contentSizeForViewInPopover = CGSizeMake(320.0, 250.0f);
self.navigationItem.title = @"Print / Email";
self.title = @"Print / Email";
}
But in no cases the title is working, am I still doing something wrong?