【发布时间】:2012-08-21 06:11:49
【问题描述】:
我试图在UIPopoverController 中显示UINavigationController,但由于某种原因我无法设置标题。
SearchViewController *searchView = [[[SearchViewController alloc] init] autorelease];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:searchView];
[popover presentPopoverFromBarButtonItem:_searchBarButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
我尝试在- (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;
}
我也尝试在- (void)viewDidLoad中设置它
- (void)viewDidLoad
{
[super viewDidLoad];
self.contentSizeForViewInPopover = CGSizeMake(320.0, 250.0f);
self.navigationItem.title = @"Print / Email";
self.title = @"Print / Email";
}
但在任何情况下标题都不起作用,我还是做错了什么吗?
【问题讨论】:
-
尝试从 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 中删除 titleview 标签代码。
标签: iphone ios uinavigationcontroller uipopovercontroller