0

在这个使用 iOS 6 SDK 创建的应用程序中,我使用本文中描述的这种方法模块化我的故事板。基本上它所做的是,它以UITabBarController编程方式创建一个并将每个情节提要作为选项卡嵌入其中。

这在 iOS 6 中运行良好,但在 iOS 7 中,它似乎出错了。当我运行它时,应用程序会冻结。无法点击选项卡以切换到它们和所有。即使是选项卡内的按钮等控件也不会收到点击。

最糟糕的是它甚至不会抛出任何错误或警告。在这方面也没有使用过时的 API。我不知道为什么这不起作用。

我已经联系了写这篇文章的作者并告知了他这个问题,但我还没有收到他的任何回复。与此同时,我想在这里问一下。

我创建了一个演示此问题的项目并将其上传到此处。它使用 Xcode 4.6 和 iOS 6.1 创建。当您在 iOS 6 中运行它时,它可以正常工作,但在 Xcode 5、iOS 7 中却不行。

我知道这不是一个直截了当的编程问题,但如果有人可以看看它并就如何纠正这个问题给我一个建议,我将不胜感激。

非常感谢

4

1 回答 1

1

在 -setUpTabBasedAppWithTabs:block: 方法中,您使用的是这一行:

[UIWindow new]

这相当于:

[[UIWindow alloc] init];

这相当于:

[[UIWindow alloc] initWithFrame:CGRectZero];

如果您将其更改为:

[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]

Then this works correctly. Probably the window is up in the upper right corner, but not clipping the subviews, which lets them draw but prevents them from interacting with touches.

There are a couple of other confusing things in play in this demo though that may not be present in your real application. The main storyboard is still set in the info.plist/project editor.This means that your application has another window behind the one you are creating with an instance of some of your view controllers on it.

于 2013-10-14T19:13:38.003 回答