wou*_*_be 1 iphone uinavigationcontroller uipopovercontroller ios
我正在尝试显示UINavigationController内部a UIPopoverController,但由于某种原因我无法设置标题.
SearchViewController *searchView = [[[SearchViewController alloc] init] autorelease];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:searchView];
[popover presentPopoverFromBarButtonItem:_searchBarButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Run Code Online (Sandbox Code Playgroud)
我尝试过改变它 - (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;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过设置它 - (void)viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
self.contentSizeForViewInPopover = CGSizeMake(320.0, 250.0f);
self.navigationItem.title = @"Print / Email";
self.title = @"Print / Email";
}
Run Code Online (Sandbox Code Playgroud)
但在任何情况下标题都没有用,我还在做错吗?
编辑在UINavigationController广告中添加您的SearchViewController控制器,在UIPopoverController中,如下所示:
SearchViewController *searchView = [[[SearchViewController alloc] init] autorelease];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:searchView];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navController];
[popover presentPopoverFromBarButtonItem:_searchBarButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Run Code Online (Sandbox Code Playgroud)
现在在SearchViewController的viewDidLoad方法中:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Print / Email";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3377 次 |
| 最近记录: |