Search code examples
iosuitableviewuisearchbaruipopovercontrollerios7

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?


Solution

  • 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.