我在iOS 7中遇到了新的UISearchBar问题。
我的应用程序中有一个带有搜索栏的表格视图。它是手工制作的(以编程方式添加)-在storyboard中的tableviewcontroller中,在viewDidLoad方法中,我使用从UISearchBar继承的自定义searchbar添加了searchDisplayController。
所有事情都在导航控制器中进行。
在我的应用程序逻辑中,在某个点上,我通过发送dismissViewController释放此nav控制器。
在iOS 6中,它完美运行。
但是在iOS 7中,当尝试释放导航控制器时,应用程序崩溃。
日志中出现了这些有趣的行:
在viewDidLoad的结尾,我添加了以下内容:
for (UIView *view in self.view.subviews) {
NSLog(@"%@ %p", [view.class description], view);
}
在iOS 6中,我只有以下内容:
2013-09-19 12:40:40.553 myApp[4182:c07] KRSearchBar 0x988bdd0
在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
释放导航控制器后,我已经
2013-09-19 13:09:32.419 myApp[4690:a0b] *** -[UIView release]: message sent to deallocated instance 0xa265310
什么是UIView?它来自哪里?如何处理它?
-(void)dealloc{ self.tableView; /*or self.view;*/ }
,它也可以工作...但我认为这不是最好的解决方案。 - archangertableHeaderView
(其中包含 searchBar)设置为 nil。 - de.