Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Crash when swiping away from a UITableViewController with an active UISearchController #63

Closed
gca3020 opened this issue Feb 1, 2016 · 7 comments

Comments

@gca3020
Copy link

gca3020 commented Feb 1, 2016

As stated in the title. I have a single subclass of UITableViewController that I am instantiating multiple times (holding different subsets of data in each). I have a UISearchController initialized in the viewController, and the tableView.tableHeaderView is set as searchController.searchBar.

`
let searchController = UISearchController(searchResultsController: nil)

override func viewDidLoad() {
    super.viewDidLoad()

    // Set up the search bar
    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false
    searchController.hidesNavigationBarDuringPresentation = false

    definesPresentationContext = true
    tableView.tableHeaderView = searchController.searchBar
}

`

If I click into the search field and start searching, and then switch view controllers by swiping or clicking on a new one, I get a crash.

From the debugging output, it looks like there is an exception thrown:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected subviews'

@ermalkaleci
Copy link
Owner

hey @gca3020
I am not sure what you are trying to do.
ezgif-4224294470

@gca3020
Copy link
Author

gca3020 commented Feb 1, 2016

That's strange. That's very similar to what I'm doing, except mine is crashing. Only when I have the search bar active.

Other minor differences are that my table currently has no items in it (empty array), and that I'm moving tabs between two instances of the same TableVC, both with a search bar at the top.

@gca3020
Copy link
Author

gca3020 commented Feb 1, 2016

Some additional details on the exception:
2016-02-01 06:43:17.183 MyApp[8384:2378159] *** Assertion failure in -[_UIQueuingScrollView _setWrappedViewAtIndex:withView:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/_UIQueuingScrollView.m:332 2016-02-01 06:43:17.191 MyApp[8384:2378159] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected subviews' *** First throw call stack:

A Google search shows this, which looks similar:
http://stackoverflow.com/questions/24675000/uipageviewcontroller-nsinternalinconsistencyexception

@galip91
Copy link

galip91 commented Feb 8, 2016

I am having the exact same issue with an UISearchBar. when it's in focus or firstResponder and I click on a different tab it crashes.
my code is the same as @gca3020's

@galip91
Copy link

galip91 commented Mar 2, 2016

any updates on this issue?

@ermalkaleci
Copy link
Owner

This crash is cause by UISearchController, so you should consider dismissing the search before changing tab

@anuranBarman
Copy link

I had the similar issue. If you are hiding the search bar on tab switch make sure you are hiding it in the delegate function

func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, willMoveAt index: UInt)

This will solve the problem I guess. I was playing with the constraint of the search bar. so I put the code in the above function and it worked well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants