您的位置:首页 > 产品设计 > UI/UE

UISearchBar的使用

2011-10-14 12:32 274 查看
searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake(0.0, 0.0, self.view.bounds.size.width, 40)];

searchBar.placeholder=@"Enter Name";

searchBar.delegate = self;

searchBar.showsCancelButton = YES;

theTableView.tableHeaderView = searchBar;

searchBar.keyboardType = UIKeyboardTypeDefault;

//searchBar.autocorrectionType = UITextAutocorrectionTypeNo;

//searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;

[self.view addSubview: searchBar];

//search Button clicked....

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar // called when keyboard search button pressed

{

NSLog( @"%s,%d" , __FUNCTION__ , __LINE__ );

[searchBar resignFirstResponder];

}

//cancel button clicked...

- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar // called when cancel button pressed

{

NSLog( @"%s,%d" , __FUNCTION__ , __LINE__ );

[searchBar resignFirstResponder];

}

转载:http://blog.csdn.net/iorchid/article/details/6542048
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: