UISplitView:详细视图不可见

发布于 2024-10-20 11:27:05 字数 1392 浏览 1 评论 0原文

application:didFinishLaunchingWithOptions: 中,我添加了一个分割视图:

[self.window addSubview:splitViewController.view];
[self.window makeKeyAndVisible];

splitViewController 来自应用程序委托中加载的 NIB,并且非常简单,左侧有表格视图,并且右侧的一些自定义视图。

splitViewControllershouldAutorotateToInterfaceOrientation: 中,如果 interfaceOrientation 是 UIInterfaceOrientationPortraitUIInterfaceOrientationPortraitUpsideDown,我将返回 NO(这更有意义)在我看来,只有在第一次运行时才会这样出现)。

当我在模拟器(SDK 4.2)中运行我的应用程序时,模拟器按照我的预期旋转到横向,但详细视图不可见(为黑色)。左边的表格视图就很好了。

有趣的是,当我向左或向右旋转模拟器 2 次时,详细视图按预期变为可见。

似乎一开始,详细视图位于其他视图后面,我通过记录每个视图控制器的框架来检查它(在shouldAutorotateToInterfaceOrientation:中):

Details VC frame: {{0, 20}, {768, 1004}}
SiteSelection frame: {{0, 20}, {768, 1004}}
SPLIT VC frame: {{0, 20}, {768, 1004}}

此外,分割视图控制器subviews 给出:

v: <UIView: 0x5c32d60; frame = (0 20; 768 1004); layer = <CALayer: 0x5c335e0>>
v: <UILayoutContainerView: 0x5c94dc0; frame = (0 0; 768 1004); clipsToBounds = YES; layer = <CALayer: 0x5c94e10>>

因此,似乎由于某种原因,表视图占用了整个 iPad 的窗口框架,并且与详细自定义视图重叠。

这是正确的吗?这背后的原因可能是什么?在 NIB 中一切似乎都很好。我怀疑应该归咎于 shouldAutorotateToInterfaceOrientation: 。我该如何解决这个问题?

In application:didFinishLaunchingWithOptions: I'm adding a split view:

[self.window addSubview:splitViewController.view];
[self.window makeKeyAndVisible];

splitViewController comes from NIB loaded in app delegate, and is pretty simple one, with table view on the left, and some custom view on the right.

In shouldAutorotateToInterfaceOrientation: of splitViewController I'm returning NO if interfaceOrientation is either UIInterfaceOrientationPortrait or UIInterfaceOrientationPortraitUpsideDown(it makes more sense in my up to show up like this only during the 1st run).

When I run my app in the simulator (SDK 4.2), simulator is rotating to the landscape orientation as I expect, but detail view is not visible (is black). Table view on the left is just fine.

What's interesting, when I rotate simulator 2 times left or right, the detail view turns visible as expected.

It seems that at the beginning the detail view is behind some other view, I checked it by logging each view controllers' frame (in shouldAutorotateToInterfaceOrientation:):

Details VC frame: {{0, 20}, {768, 1004}}
SiteSelection frame: {{0, 20}, {768, 1004}}
SPLIT VC frame: {{0, 20}, {768, 1004}}

Also, split view controller subviews gives:

v: <UIView: 0x5c32d60; frame = (0 20; 768 1004); layer = <CALayer: 0x5c335e0>>
v: <UILayoutContainerView: 0x5c94dc0; frame = (0 0; 768 1004); clipsToBounds = YES; layer = <CALayer: 0x5c94e10>>

So it seems that for some reason table view is taking whole iPad's window frame, and is overlapping with detail custom view.

Is that correct? What could be the reason behind that? In NIB everything seems fine. I suspect that shouldAutorotateToInterfaceOrientation: is to blame. How can I fix that?

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

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

发布评论

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

评论(1

∞梦里开花 2024-10-27 11:27:05

你猜怎么着...在 Xcode4 下运行完全相同的代码就可以了。
所以我不清楚 Xcode3.x 或者更可能是 iOS Simulator 下出了什么问题。

Guess what... Running exactly the same code under Xcode4 works just fine.
So it's unclear to me what is wrong under Xcode3.x, or more likely, iOS Simulator.

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