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...》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

Database Design and Implementation

Database Design and Implementation

Edward Sciore / Wiley / 2008-10-24 / 1261.00 元

* Covering the traditional database system concepts from a systems perspective, this book addresses the functionality that database systems provide as well as what algorithms and design decisions will......一起来看看 《Database Design and Implementation》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

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

html转js在线工具