New UISearhBar in ios 7

Hi guys.

I have some problems with the new uisearchbar in iOS 7

in my application there is a tableview with a search bar in tableHeaderView this is manual work (added programmatically) - a tableviewcontroller in a storyboard, in the viewDidLoad method I add a searchDisplayController with my custom search bar inherited from UISearchBar.

everything that happens in the navigation controller.

in the logic of my application at some point I will let go of this navigation controller sending rejectViewController

On ios 6, it works great.

but in ios 7 I get crashes when trying to start the navigation controller.

in the log I have interesting lines ...

to the end of viewDidLoad I add the following:

for (UIView *view in self.view.subviews) { NSLog(@"%@ %p", [view.class description], view); } 

in ios 6 i only have this

 2013-09-19 12:40:40.553 myApp[4182:c07] KRSearchBar 0x988bdd0 

in ios 7:

 2013-09-19 13:08:47.808 myApp[4690:a0b] UIView 0xa265310 2013-09-19 13:08:47.809 myApp[4690:a0b] UITableViewWrapperView 0xa25b4d0 2013-09-19 13:08:47.810 myApp[4690:a0b] KRSearchBar 0xa2591b0 

and after the release of the navigation controller I have

 2013-09-19 13:09:32.419 myApp[4690:a0b] *** -[UIView release]: message sent to deallocated instance 0xa265310 

So ... who knows what UIView is? where does it come from and how to deal with it?

+4
source share
1 answer

iOS 7 has changed some rules regarding table views and their delegate. Of course, this is not highlighted somewhere easy to find.

But basically, in an earlier version of iOS, you could disable the tableView delegate and datasource. No error messages were made.

From iOS 7, you MUST use them in your dealloc, otherwise it may cause this to crash.

 - (void)dealloc { fetchedResultsController.delegate = nil; self.searchDisplayController.delegate = nil; self.searchDisplayController.searchResultsDelegate = nil; self.searchDisplayController.searchResultsDataSource = nil; self.tableView.delegate = nil; self.tableView.dataSource = nil; } 

Let me know if this solves your problem.

+17
source

All Articles