如何在 iPhone 上的 UIPopovercontroller 中显示 NavigationController 的背景(包括标题/按钮)?
目前它看起来像这样:
在我的 PopoverView-ViewController 中:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden = NO;
self.navigationController.navigationBarHidden = NO;
self.navigationItem.title = @"self.navigationItem.title";
}
调用 Popover 时:
InfoView *iv = [[InfoView alloc] initWithNibName:@"InfoView" bundle:nil];
UINavigationController *uc = [[UINavigationController alloc] initWithRootViewController:iv];
self.pop = [[UIPopoverController alloc] initWithContentViewController:uc];
[self.pop setDelegate:self];
[self.pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:true];
它应该如下所示:
最佳答案
起初 UINavigationController 没有自己的背景,它显示内容 View Controller 的背景。如果您可以成功显示带有导航 Controller 的弹出框,请检查您的 InfoView。它的观点有一些背景吗?
其次,我尝试在 iPhone 上以不同的配置多次执行您的代码,但总是收到错误
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController initWithContentViewController:] called when not running under UIUserInterfaceIdiomPad.
这对我来说并不奇怪。即使你能让它工作,Apple 也可能会拒绝你的申请。
2.1 崩溃的应用会被拒绝 - 只需在多个设备上测试您的代码并查看结果。
关于iphone - 如何在 iPhone 上的 UIPopoverController 中显示 NavigationController-background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9242214/