在导航栏下添加搜索栏?

问题描述:

我想用uitableview在导航栏下添加一个搜索栏。 ,我想从数据库中搜索? 任何想法如何做到这一点在导航栏下添加搜索栏?

添加搜索栏作为您的表的headerView。

UISearchBar *temp = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 45)]; 
temp.barStyle=UIBarStyleBlackTranslucent; 
temp.showsCancelButton=YES; 
temp.autocorrectionType=UITextAutocorrectionTypeNo; 
temp.autocapitalizationType=UITextAutocapitalizationTypeNone; 
temp.delegate=self; 
self.tableView.tableHeaderView=temp; 
[temp release];