在我们的应用程序,我们有具有UISearchController一个UITableViewController:与UISearchController取消搜索导致崩溃
searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
[self.searchController.searchBar sizeToFit];
self.tableView.tableHeaderView = self.searchController.searchBar;
self.showFooterView = YES;
self.searchController.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO; // default is YES
self.searchController.searchBar.delegate = self;
self.definesPresentationContext = YES;
表视图控制器也是一个UISearchBarDelegate 和UISearchControllerDelegate。
#pragma mark - UISearchBarDelegate
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[searchBar resignFirstResponder];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
self.contacts = self.allContacts;
[self.tableView reloadData];
}
现在一切正常,但存在这样的情况,当用户开始搜索,类型在搜索栏中几个字符,返回结果,用户取消搜索,然后出现这种情况:
Fatal Exception: NSInvalidArgumentException
-[_UIFullscreenPresentationController adaptivePresentationController]: unrecognized selector sent to instance 0x147c81ce0
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x1842b4f48 __exceptionPreprocess
1 libobjc.A.dylib 0x198d77f80 objc_exception_throw
2 CoreFoundation 0x1842bbc5c __methodDescriptionForSelector
3 CoreFoundation 0x1842b8c00 ___forwarding___
4 CoreFoundation 0x1841bccac _CF_forwarding_prep_0
5 UIKit 0x18a1ba084 -[UISearchController _searchPresentationController]
6 UIKit 0x189e7d10c -[_UISearchControllerTransplantSearchBarAnimator animateTransition:]
7 UIKit 0x189b9fa90 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke
8 UIKit 0x189af856c _runAfterCACommitDeferredBlocks
9 UIKit 0x189b054bc _cleanUpAfterCAFlushAndRunDeferredBlocks
10 UIKit 0x189839984 _afterCACommitHandler
11 CoreFoundation 0x18426bbd0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
12 CoreFoundation 0x184269974 __CFRunLoopDoObservers
13 CoreFoundation 0x184269da4 __CFRunLoopRun
14 CoreFoundation 0x184198ca0 CFRunLoopRunSpecific
15 GraphicsServices 0x18f3d4088 GSEventRunModal
16 UIKit 0x1898b0ffc UIApplicationMain
我们从来没有能够重现这个错误,虽然它在Fabric上被生产报告。
此问题与此类似:Selecting cell after search doesn't segue visually, but loads next view Swift Xcode但尚未给出真正的答案。
我已经开始关注演示文稿控制器,但我们没有特殊的功能,需要以特定的方式设置演示文稿控制器。
有关如何解决此问题的任何想法?
谢谢
您是否找到答案。或者仍然面临着这个问题。确定这是你的代码级别的问题。你正在尝试访问,但那不是在内存 – karthik