如何在 iPhone 上的 UIPopoverController 中显示 NavigationController 背景
如何在 iPhone 上的 UIPopovercontroller 中显示 NavigationController 的背景(包括标题/按钮)?
目前看起来像这样:
在我的 PopoverView-ViewController 中:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden = NO;
self.navigationController.navigationBarHidden = NO;
self.navigationItem.title = @"self.navigationItem.title";
}
< strong>调用 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];
应该如下所示:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(5)
不再让梦枯萎 2025-01-12 08:21:01
您的代码
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];
是完美的,只需隐藏默认导航控制器并在 InfoView.xib 的 XIB 中添加一个 navigationBar 并在那里编写 cancelButtonAction 来执行视图的解除或表格视图选择的详细信息。它工作正常,请检查我以相同方式完成的图像,并相信我它工作正常。
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
首先 UINavigationController 没有自己的背景,它显示内容视图控制器的背景。如果您可以成功地使用导航控制器显示弹出窗口,请检查您的 InfoView。它的观点有什么背景吗?
其次,我尝试在iPhone上以不同的配置多次执行你的代码,但总是收到错误
这对我来说并不奇怪。即使你能成功,苹果也可能会拒绝你的申请。
2.1 崩溃的应用程序将被拒绝 - 只需在多个设备上测试您的代码并查看结果。
At first UINavigationController doesn't have own background, it shows background of content view controller. If you can show popover with navigation controller successfully, then check your InfoView. Does it's view has some background?
Second, I tried to execute your code multiple times in different configurations on iPhone, but always have received error
And that was not surprise for me. Even if you could make it work, then Apple may reject your application.
2.1 Apps that crash will be rejected - Just test your code on several devices and see result.