gpt4 book ai didi

iphone - UIPopoverController 中的 UINavigationController : setting the title

转载 作者:行者123 更新时间:2023-12-01 17:27:01 24 4
gpt4 key购买 nike

我正在尝试显示 UINavigationControllerUIPopoverController 内,但由于某种原因,我无法设置标题。

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";
}

但是在任何情况下标题都不起作用,我还是做错了什么吗?

最佳答案

编辑 在 UINavigationController 广告中添加您的 SearchViewController Controller ,在 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];

现在在 SearchViewController 的 viewDidLoad 方法中:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Print / Email";
}

引用 setting-the-title-of-a-uipopovercontroller

关于iphone - UIPopoverController 中的 UINavigationController : setting the title,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12049241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com