我的 iOS 6 应用程序有一个简单的工作流程:
UINavigationController -> loadingVC -(push)-> UITabBarController -> UIViewController(s)
我调用 push via performSegueWithIdentifier:
,使用观察者 on 调用自身NSNotificationCenter
,但是加载 UITabBarController 的根 VC 需要太多时间(约 35 秒)。
这是我在 loadingVC 中注册观察者的方式:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadingDidComplete) name:@"dataDoneLoading" object:nil];
然后,我的 loadingVC 从我的 AppDelegate 调用一些方法,该方法将继续处理一些网络内容(获取和解析 XML 文件),并等待将触发的通知:
[self performSegueWithIdentifier:@"finishedLoading" sender:self];
这是我在加载根 VC 时得到的控制台日志UITabBarController
:
2013-05-06 16:28:19.720 *** [2289:19303] Notif sent
2013-05-06 16:28:19.720 *** [2289:19303] Notif received
2013-05-06 16:28:19.727 *** [2289:19303] viewDidLoad in (some basic stuff)
2013-05-06 16:28:19.728 *** [2289:19303] viewDidLoad out
2013-05-06 16:28:19.729 *** [2289:19303] viewWillAppear (NSLog only)
2013-05-06 16:28:54.475 *** [2289:19303] In numberOfSections (datasource method of a UITableview, returns 0)
2013-05-06 16:28:54.832 *** [2289:12b03] viewDidAppear (NSLog only)
如您所见,viewWillAppear
在推送实际发生之前,我有 35 秒的时间。该应用程序挂在 上loadingVC
,然后像往常一样推送。
所有这些都发生在模拟器中(我暂时无法在物理设备上进行测试)。
我尝试了什么:
• 我使用SDSegmentedControl
, 的子类UISegmentedControl
,但我尝试使用后者,同样的问题发生了。
• 我删除了我UINavigationController
的并用模态segue 替换了push。它似乎工作得更快,但 UI 完全搞砸了:在 segue 期间没有动画(即使我将其设置为“是”),标签栏不会在段上显示文本或图标,直到你点击它们,我的分段控件不出现。
我似乎无法理解发生了什么。有什么帮助吗?