Application tried to present modal view controller on itself Presenting controller is UISea...

栏目: IOS · 发布时间: 6年前

内容简介:近几天在测试公司项目时,遇到一个UISearchController崩溃的问题。问题似乎是iOS11之后,系统试图恢复firstResponder状态。在关闭视图之前,设置searchController的active为NO,例如:

近几天在测试公司项目时,遇到一个UISearchController崩溃的问题。

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'Application tried to present modal view controller on itself. 
Presenting controller is <UISearchController: >.'

崩溃的原因

问题似乎是iOS11之后,系统试图恢复firstResponder状态。

解决办法

在关闭视图之前,设置searchController的active为NO,例如:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   self.searchController.active = NO; // Add this !
   ...

   [self dismissViewControllerAnimated:YES completion:nil];
}

以上所述就是小编给大家介绍的《Application tried to present modal view controller on itself Presenting controller is UISea...》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

VC++.NET入门

VC++.NET入门

Davis Chapman / 中国电力出版社 / 2003-5 / 55.0

《VC++.NET入门》提供了学习Visual C++工具的循序渐进的指导和创建应用程序的向导。你将学习设计应用程序窗口、使用控件、显示图形、创建SDI和MDI应用程序、操作数据库以及创建多任务程序,也将学习在微软的新.E平台下使用Visual C++的一些基本技巧,以及学习它影响设计和编写应用程序的方式。一起来看看 《VC++.NET入门》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具