I’m not sure why this isn’t working as it is working in another area of my app. I am trying to display the title for the navigationController that is the contentViewController of the popover. This is the code:
DetailView* details = [[[DetailView alloc] initWithTarget:target] autorelease];
UINavigationController* content = [[[UINavigationController alloc] initWithRootViewController:details] autorelease];
self.popover = [[[UIPopoverController alloc] initWithContentViewController:content] autorelease];
[self.popover setDelegate:self];
}
[self.popover presentPopoverFromRect:frame inView:self.scrollView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Than in my DetailView.m:
- (id)initWithTarget:(Target*)aTarget
{
self = [super initWithNibName:@"TargetDetailView" bundle:nil];
if (self) {
// Custom initialization
target = [aTarget retain];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"Target";
}
I have also tried
content.navigationItem.title = @"Target";
but that does not give me a title in my popover. Any thoughts? TIA.
put this in viewWillAppear:animated
I suspect that viewDidLoad is getting called on the DetailView before it is a part of the UINavigationController and therefore it might not have a navigationItem at that time.