当我使用 -initWithNibName:bundleName: 初始化 UISplitViewController 时,为什么它是黑色的?

发布于 2024-10-01 18:48:09 字数 229 浏览 2 评论 0原文

苹果在参考文献中说我应该使用-init。但这似乎违反了始终使用指定初始化程序的约定。因为它没有任何一个,所以它将是来自超类 UIViewController 的一个,对吧?如果我现在完全清醒的话,那就是 -initWithNibName:bundleName:。

然而,当使用 nil 和 nil 调用它时,UISplitViewController 是全黑的。当我调用 -init insetead 时,它工作得很好。别明白。

Apple says in a ref I should use -init. But that seems to go against the convention of always using the designated initializer. Since it doesn't have any, it would be the one from the superclass which is UIViewController, right? And there, it is -initWithNibName:bundleName:, if I'm fully awake right now.

However, when calling that with nil and nil, the UISplitViewController is fully black. When I call -init insetead, it works perfectly. Don't get it.

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

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

发布评论

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

评论(2

他夏了夏天 2024-10-08 18:48:09

请参阅此处:将 UISplitViewController 放在自己的 XIB 中?

可能会有所帮助你。看来你不能也不应该那样做。我在尝试时遇到了同样的黑屏。把它放到主 XIB 上就可以了。不过很奇怪。

哦,还看到这个: UISplitviewcontroller not as a rootview controller

它增强了我的信念:这是不可能的。奇怪的。

勒内

See here: Stick UISplitViewController in its own XIB?

Might help you. It seems you just cannot and should not do it that way. I'm experiencing the same black screen when trying it. Put it to the main XIB and you're fine. Weird though.

Oh, and also see this: UISplitviewcontroller not as a rootview controller

It strengthens my belief: it is not possible. Odd.

René

如梦初醒的夏天 2024-10-08 18:48:09

就我而言,我没有打电话

[window makeKeyAndVisible];

[window addSubview:self.splitViewController.view];

导致黑屏。我正在初始化它,因为

self.splitViewController = [[UISplitViewController alloc] init];

添加 [window makeKeyAndVisible]; 解决了问题。

In my case, i was not calling

[window makeKeyAndVisible];

after

[window addSubview:self.splitViewController.view];

which caused the black screen. I was initializing it as

self.splitViewController = [[UISplitViewController alloc] init];

Adding [window makeKeyAndVisible]; fixed the problem.

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