我正在构建一个使用大量web服务的iOS应用程序。这个应用程序有一个UItabBarController作为它的根VC。
在我的一个控制器中,我将viewController推到UINavigationController上。我正在推到堆栈上的ViewController是一个带有来自web的数据的UITableView的UITableViewController。我在每个级别恢复控制器,用户在数据中下降。然后,在最后一层,我调用一个web服务,然后希望整个UITableViewController被取消,原始视图控制器被显示出来。
这就是它的样子:
ViewControllerA (UIViewController) ->用户点击按钮-推ViewControllerB到它上。(UINavigationController)。
一旦我完成了与ViewControllerB,我需要它被解雇和ViewControllerA显示的结果。
在ViewControllerB中,我在NSNotification方法中这样做:
if ([errorString hasPrefix:@"No descendants"]){
UINavigationController *navigationController =
[self.tabBarController.viewControllers objectAtIndex:1];
BBSearchViewController *searchViewController =
navigationController.viewControllers[0];
searchViewController.categoryId = self.categoryId;
if (searchViewController.brwosingCategoriesFromSearchPage){
[[BBDataStore sharedDataStore]deRegisterForNotifications:self];
[self.navigationController popToRootViewControllerAnimated:NO];这将导致控制台中的此错误:
> 2014-05-08 09:32:16.306 TestApp[36948:60b] Finishing up a navigation transition
in an unexpected state. Navigation Bar subview tree might get corrupted.
2014-05-08 09:32:16.780 TestApp[36948:60b] Unbalanced calls to begin/end
appearance transitions for <ViewControllerA: 0xd08aa00>.有人能告诉我我在这里做错了什么吗?
发布于 2014-05-08 08:59:00
您得到这些错误是因为您正在尝试一个转换之前,另一个已经完成。在您的例子中,您似乎在视图出现之前收到通知,然后尝试弹出到根。您应该使用用户输入(当用户点击按钮时)或至少在popToRootViewControllerAnimated:之后调用viewDidAppear:。
https://stackoverflow.com/questions/23535663
复制相似问题