I want to use an UISearchDisplayController
on UIViewController
, that includes an UITableView
.
I use Autolayout. When i try to put the SearchBar (_searchBar) in the tableHeaderView with
self.tableView.tableHeaderView = _searchBar;
I get the error
'NSInternalInconsistencyException
', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'
Disabling Autolayout, the error disappears, but i need Autolayout...
The error appears, when I use Custom Cells or StandardCells...
The error appears, when the TableView has no rows...
As a general solution to this problem, or at least a way of finding the cause of it:
UITableView
and override layoutSublayersOfLayer:
, just calling superpo [self _autolayoutTrace]
This will show you a printout of every view in the window, with the views where auto layout has not been able to come up with a solution highlighted by asterisks or AMBIGUOUS LAYOUT
. These are the views you need to investigate the constraints for.
When adding a subview to UITableView there are some specific requirements for the subview. Consider adding the subview to another view(superview) in your controller instead of UITableView.
"Auto Layout still required after executing -layoutSubviews" with UITableViewCell subclass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With