在导航栏下添加搜索栏?

Rah*_*yas 3 iphone cocoa-touch objective-c

我想在导航栏下面添加一个带有uitableview的搜索栏.我想从数据库中搜索?任何想法如何做到这一点

zpe*_*esk 8

将搜索栏添加为表格的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];
Run Code Online (Sandbox Code Playgroud)