UISplitViewController 内的 UIPopOverController

发布于 12-22 21:43 字数 882 浏览 5 评论 0原文

我必须在一个 splitController 的左侧显示一个 popOver,我用导航控制器初始化 popOver。但是当我显示 popOver 时,我的应用程序崩溃了。

Impostazioni *settings = [[Impostazioni alloc] initWithStyle:UITableViewStyleGrouped];
settings.title = NSLocalizedString(@"SETTINGS", nil);
settings.contentSizeForViewInPopover = kContentSizeOfPopOver;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:settings];
nav.navigationBar.tintColor = kTintColorNavigationBar;
nav.contentSizeForViewInPopover = kContentSizeOfPopOver;
UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:nav];
[popOver presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];

这是我的代码。有什么想法吗?

编辑:即使我只设置一个viewController而不是SplitController也会崩溃:/并且使用一个空的ViewController:/

I have to show one popOver inside the left side of one splitController, I initialize the popOver whit an navigationController. But when i show the popOver my app crash.

Impostazioni *settings = [[Impostazioni alloc] initWithStyle:UITableViewStyleGrouped];
settings.title = NSLocalizedString(@"SETTINGS", nil);
settings.contentSizeForViewInPopover = kContentSizeOfPopOver;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:settings];
nav.navigationBar.tintColor = kTintColorNavigationBar;
nav.contentSizeForViewInPopover = kContentSizeOfPopOver;
UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:nav];
[popOver presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];

This is my code. Any ideas?

EDIT: Crash even if I set only a viewController instead of SplitController :/ And with a empty ViewController :/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

看春风乍起2024-12-29 21:43:33

(可能与 Error using UIPopoverController 重复。)

简而言之,您需要保留 UIPopoverController< /code> 不知何故。通过为其定义属性或手动管理引用计数。对于 ARC,后者不是一个选项,因此您需要存储引用。

(Possibly duplicate of Error using UIPopoverController.)

In short, you need to retain the UIPopoverController somehow. Either by defining a property for it or by managing the ref count manually. With ARC, the latter is not an option, so you need to store the reference.

染年凉城似染瑾2024-12-29 21:43:33

我相信您需要一个实例变量来保存 popoverController。否则,在包含您显示的代码的方法完成后,将不会保留您的弹出窗口。与将子视图添加到视图时不同,视图将保留子视图。对于弹出窗口来说,同样的事情不会发生。

I believe you need an instance variable to hold the popoverController. Otherwise after the method that contains the code that you showed finishes nothing will have retained your popover. Unlike when you add a subview to a view which the view would then retain the subview. The same thing does not take place for popovers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文