【发布时间】:2012-01-01 23:18:59
【问题描述】:
我正在尝试以编程方式创建 UISearchDisplayController。我有一个方法应该设置我的搜索控制器,但是当我调用它时,什么也没有发生。
这是我的-setupSearch 方法:
- (void)setupSearch {
UISearchBar *myBar;
UISearchDisplayController *myCon;
myBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
[myBar sizeToFit];
myCon = [[UISearchDisplayController alloc]
initWithSearchBar:myBar contentsController:self];
[myBar release];
myCon.delegate = self;
myCon.searchResultsDataSource = self;
myCon.searchResultsDelegate = self;
/* Setup scopes */
{
NSMutableArray *scopes;
NSUInteger count, i;
NSString *aScope;
count = SCOPE_COUNT;
scopes = [[NSMutableArray alloc] initWithCapacity:count];
for(i = 0; i < count; i++) {
// I create four scopes here
}
myCon.searchBar.scopeButtonTitles = scopes;
[scopes release];
}
[myCon release];
}
我在我的子类UITableViewController 的-viewDidLoad 方法中调用上述方法。不幸的是,当我的表格视图控制器显示在 UITabBarController 中时,什么也没有发生。
任何帮助将不胜感激。
【问题讨论】:
标签: ios uisearchdisplaycontroller