gpt4 book ai didi

ios - searchBarCancelButtonClicked popToRootViewControllerAnimated

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:08:23 25 4
gpt4 key购买 nike

我有两个 View ,一个是 Root View Controller ,另一个是搜索 View Controller 。当我在搜索 viewController 的 UISearchBar 上单击取消时,我想返回到根 viewController。我有这段代码:

-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
[self.navigationController popToRootViewControllerAnimated:YES];
}

但是当我点击取消时,我得到这个错误:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'search contents navigation controller must not change between -setActive:YES and -setActive:NO'

我做错了什么? [self.navigationController popToRootViewControllerAnimated:YES]; 在我的搜索 View 的其他区域工作。

最佳答案

在弹出导航 Controller 之前,您需要先隐藏搜索显示 Controller :

[self.searchDisplayController setActive:NO];

这将隐藏没有动画的搜索界面。

关于ios - searchBarCancelButtonClicked popToRootViewControllerAnimated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17269635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com