Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView with a UISearchBar as the header view causes crashes

I have a popover with a UITableViewController as the content view controller. The table view has a UISearchBar as its header view.

Everything is ok on iOS 6, but on iOS 7 the app crashes when closing the popover giving this error:

*** -[UIView release]: message sent to deallocated instance 0x118a9bf0

Call stack

Any idea about the possible cause for this crash?

like image 420
Hejazi Avatar asked Sep 22 '13 16:09

Hejazi


2 Answers

I ended up calling [searchBar removeFromSuperview] in dealloc - same fix.

like image 184
steipete Avatar answered Nov 09 '22 12:11

steipete


This is how I fixed it. I set the table's header view to nil when the view controller is being deallocated:

- (void)dealloc {
    self.tableView.tableHeaderView = nil;
}

Though, this doesn't explain the real reason for the crash.

like image 7
Hejazi Avatar answered Nov 09 '22 14:11

Hejazi