通过UINavigationController错误向后导航 [英] Navigating Backwards through a UINavigationController Error

查看:117
本文介绍了通过UINavigationController错误向后导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UINavigationController进入一个加载数据的ViewController。然后,此ViewController将转换为TabViewController。这个TabViewController有两个选项卡,每个选项卡转到另一个UITableViewController。那两个TableViewController然后segue到相同的DetailsViewController。

现在从DetailVC向后导航时出现此错误:

I have a UINavigationController which goes into a ViewController that loads data. This ViewController then segues to TabViewController. This TabViewController has two tabs, each Tab goes to a different UITableViewController. Those two TableViewController then segue to the same DetailsViewController.
Now when navigating backwards from the DetailVC I get this error:


嵌套推送动画可能导致导航栏损坏

完成意外状态下的导航过渡。
导航栏子视图树可能已损坏。

* 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'无法将self添加为子视图'。

nested push animation can result in corrupted navigation bar
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't add self as subview'.

同样,两个TableViews的设置方式相同,但是底部的表视图从框架的顶部开始,因此它的部分被导航模糊了吧。

Also both TableViews are set up the same way but the bottom table view begins at the top of the frame so its partial obscured by the navigation bar.

推荐答案

我有一个表格视图和一个搜索栏控制器。我在表格视图单元格上创建了​​push segue并执行了通过搜索控制器以编程方式选择搜索项目。当导航回异常时触发。当你一次执行两次相同的segue时会发生这种异常。

I have a table view and a search bar controller on it.I created push segue on table view cell and performed push on selecting search item via search controller programatically.When navigated back exception fired.This exception happens when you perform same segue twice at a time.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
(NSIndexPath*)indexPath
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{

    [self performSegueWithIdentifier:@"showDetail"sender:self];
}
}

因为表格视图执行两次相同的segue在故事板中创建的单元格选择和搜索结果单元格选择中的另一个
所以检查何时执行segue

Since it was performing same segue twice one for table view cell selection created in storyboard and another for search result cell selection. So check when to perform segue

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
if (self.tableView == self.searchDisplayController.searchResultsTableView)
{

    [self performSegueWithIdentifier:@"showDetail"sender:self];
    return YES;
}

return NO;
}

这完美无缺。

这篇关于通过UINavigationController错误向后导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆