我在使用带有 UITableView 的 UISearchDisplayController 时遇到了僵尸。
UISearchDisplayController(和视图的其余部分)是通过界面构建器设置的(xcode 5 上的故事板,仅使用 ARC 和 iOS 7)。
searchDisplayController 由这两种方法使用
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
[self filterContentForSearchText:searchString scope:
[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
return YES;
}
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption {
[self filterContentForSearchText:self.searchDisplayController.searchBar.text scope:
[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]];
return YES;
}
Instruments 正在给我这个信息
# Event Type ∆ RefCt RefCt Timestamp Responsible Library Responsible Caller
0 Malloc +1 1 00:10.739.188 UIKit -[UITableView setTableHeaderBackgroundColor:]
1 Retain +1 2 00:10.739.214 UIKit -[UIView(Internal) _addSubview:positioned:relativeTo:]
2 Retain +1 3 00:10.739.234 UIKit -[UISearchDisplayController _configureSearchBarForTableView]
3 Retain +1 4 00:10.739.291 UIKit -[UIView(Hierarchy) subviews]
4 Retain +1 5 00:10.771.238 UIKit -[UIView(Hierarchy) subviews]
5 Retain +1 6 00:10.782.890 QuartzCore -[CALayer layoutSublayers]
6 Release -1 5 00:10.782.891 QuartzCore -[CALayer layoutSublayers]
7 Release -1 4 00:10.792.538 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
8 Release -1 3 00:15.446.447 UIKit -[UITableView dealloc]
9 Release -1 2 00:15.446.661 UIKit -[UIView(Internal) _invalidateSubviewCache]
10 Release -1 1 00:15.446.679 UIKit -[UIView(Hierarchy) removeFromSuperview]
11 Release -1 0 00:15.446.744 UIKit -[UITableView setTableHeaderBackgroundColor:]
12 Zombie -1 00:15.446.765 UIKit -[UISearchDisplayController _cleanUpSearchBar]
我试图像这样在 dealloc 方法中清理 UISearchDisplayController
-(void)dealloc {
self.searchDisplayController.searchResultsTableView.delegate = nil;
self.searchDisplayController.delegate = nil;
self.searchDisplayController.searchBar.delegate = nil;
self.searchDisplayController.searchResultsDelegate = nil;
self.searchDisplayController.searchResultsDataSource = nil;
}
但它没有用。
你知道我做错了什么吗?
谢谢您的帮助。