I have a TableView that is mainly intended for users to search from a list of names. I have a search, so they can enter a name, and he will search for this person.
When they select a cell, all it does is wrap the name string in the next view. It works great when no one is looking, and you just select a cell in the table. However, when you search for a name and then select, you click on the cell and it becomes gray. Then it loads the next display, but does not show it. Then, when I click โCancelโ in the search bar, it crashes the application. I am not sure what to do / what this error is.
var appleProducts = ["I am using a custom name"] var filteredAppleProducts = [String]() var resultSearchController = UISearchController() override func viewDidLoad() { super.viewDidLoad() self.loadNames() self.resultSearchController = UISearchController(searchResultsController: nil) self.resultSearchController.searchResultsUpdater = self self.resultSearchController.dimsBackgroundDuringPresentation = false self.resultSearchController.searchBar.sizeToFit() self.resultSearchController.searchBar.placeholder = "Type Name Here" self.tableView.tableHeaderView = self.resultSearchController.searchBar self.tableView.reloadData() } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if (self.resultSearchController.active) { return self.filteredAppleProducts.count } else { return self.appleProducts.count } } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! AddSearchTableViewCell if (self.resultSearchController.active) { cell.name.text = self.filteredAppleProducts[indexPath.row] return cell } else { cell.name.text = self.appleProducts[indexPath.row] return cell } } func updateSearchResultsForSearchController(searchController: UISearchController) { self.filteredAppleProducts.removeAll(keepCapacity: false) let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text!) let array = (self.appleProducts as NSArray).filteredArrayUsingPredicate(searchPredicate) self.filteredAppleProducts = array as! [String] self.tableView.reloadData() } override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
Thanks in advance for any suggestions.
error:
[_UIFullscreenPresentationController adaptivePresentationController]: unrecognized selector sent to instance 0x7f890abe6cf0
2016-03-02 23: 57: 39.775 XX 2 [3282: 82749] * Application termination due to an uncaught exception "NSInvalidArgumentException", reason: '- [_ UIFullscreenPresentationController adaptivePresentationController]: unrecognized selector sent to instance 0x7f890abe6cf0' First cast of challenges: (0 CoreFoundation 0x000000010e1cff65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010d8c1deb objc_exception_throw + 48 2 CoreFoundation 0x000000010e1d858d - [NSObject (NSObject) doesNotRecognizeSelector:] + 205 3 shipment CoreFoundation 0x000000010e125f7a ___ _ + 970 4 CoreFoundation 0x000000010e125b28 _CF_forwarding_prep_0 + 120 5 UIKit 0x000000010f3e7389 - [UISearchController _searchPresentationController] + 134 6 UIKit 0x000000010efc3755 - [_ UISearchControllerTransplantSearchBarAnimator animateTransition:] + 215 7 UIKit 0x00 0000010eb6dede 56- [UIPresentationController runTransitionForCurrentState] _block_invoke + 2638 8 UIKit 0x000000010ea1a4be _runAfterCACommitDeferredBlocks + 317 9 UIKit 0x000000010ea2c7ee _cleanUpAfterCAFlushAndRunDeferredBlocks + 95 10 UIKit 0x000000010ea384e6 _afterCACommitHandler + 90 11 CoreFoundation 0x000000010e0fb9d7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + December 23 CoreFoundation 0x000000010e0fb947 __CFRunLoopDoObservers + 391 13 CoreFoundation 0x000000010e0f159b __CFRunLoopRun + 1147 14 CoreFoundation 0x000000010e0f0e98 CFRunLoopRunSpecific + 488 15 Graphics Services 0x0000000110d54ad2 GSEventRunModal + 161 16 UIKit 0x000000010ea0e676 UIApplicationMain + 171 17 XX 0x000000010bccac4d main + 109 18 libdyld.dylib 0x0000000101141ba92d start + 1 19 ??? 0x0000000000000001 0x0 + 1) lib ++ abi.dylib: termination with an uncaught exception of type NSException (lldb)
source share