iphone - 如何在 iPhone 上的 UIPopoverController 中显示 NavigationController-background

标签 iphone ios cocoa-touch uikit uipopovercontroller

如何在 iPhone 上的 UIPopovercontroller 中显示 NavigationController 的背景(包括标题/按钮)?

目前它看起来像这样:

enter image description here

在我的 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];

它应该如下所示:

enter image description here

最佳答案

起初 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/

相关文章:

javascript - 在 iPhone 上使用 javascript 打开电子邮件

ios - webdriveragentrunner iphoneos12.2-arm64.xctestrun 不存在

ios - 中文字符而不是非拉丁字符(Mojibake 错误?!)

ios - 使用 CLLocation 计算两个坐标之间的距离

objective-c - beginTrackingWithTouch 和 touchesBegan 之间有什么区别?

iphone - 自定义 UITableViewCell 宽度在 tableview reloadData 上调整大小

iphone - iOS : Keep Http connection Open

iphone - 是否可以通过一次下载在多台 Mac 上安装 Xcode 4.3.2?

iphone - HTTP 日期格式转 NSDate

ios - iPhone 5 屏幕在我的应用程序中是黑色的,但在其他应用程序中工作正常,没有记录错误消息