我试图创建一个tableview的表头视图内的一个tableview。我想用searchDisplayController来管理一切。 我已经创建了一切以编程方式(我对IB感到不舒服)试图设置所有正确的属性,但似乎我错过了一些东西,因为当表出现时我无法编辑文本在搜索栏中看到任何动画。 下面是代码的一部分:SearchBar与searchDisplayController以编程方式编辑
- (void)viewDidLoad {
[super viewDidLoad];
UISearchBar *searchBarTMP=[[UISearchBar alloc]init];
self.searchBar=searchBarTMP;
[searchBarTMP release];
self.searchBar.autocapitalizationType=UITextAutocapitalizationTypeNone;
self.searchBar.delegate=self;
self.searchBar.showsScopeBar=YES;
self.searchBar.keyboardType=UIKeyboardTypeDefault;
self.searchBar.userInteractionEnabled=YES;
self.searchBar.multipleTouchEnabled=YES;
self.searchBar.scopeButtonTitles=[NSArray arrayWithObjects:NSLocalizedString(@"City",@"Scope City"),NSLocalizedString(@"Postal Code",@"Scope PostalCode"),nil];
self.tableView.tableHeaderView=searchBar;
self.searchBar.selectedScopeButtonIndex=0;
self.navigationItem.title=NSLocalizedString(@"Store",@"Table title");
//SearchDisplayController creation
UISearchDisplayController *searchDisplayControllerTMP = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
self.searchDisplayController=searchDisplayControllerTMP;
[searchDisplayControllerTMP release];
self.searchDisplayController.delegate=self;
self.searchDisplayController.searchResultsDelegate=self;
self.searchDisplayController.searchResultsDataSource=self;
//....continue
}
我知道,当你独自一人使用搜索栏,你必须处理其委托协议,但我猜的searchDisplayController为您管理的苹果样品中看到码。 (与IB建立起来)。
有什么建议吗? 谢谢 安德烈