UISearchBar的使用

来源:互联网 发布:js ll 和 优先级 编辑:程序博客网 时间:2024/05/18 02:51
[cpp] view plaincopy
  1. searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake(0.0, 0.0, self.view.bounds.size.width, 40)];  
  2.     searchBar.placeholder=@"Enter Name";  
  3.     searchBar.delegate = self;  
  4.     searchBar.showsCancelButton = YES;  
  5.     theTableView.tableHeaderView = searchBar;  
  6.     searchBar.keyboardType = UIKeyboardTypeDefault;  
  7.     //searchBar.autocorrectionType = UITextAutocorrectionTypeNo;  
  8.     //searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;  
  9.       
  10.     [self.view addSubview: searchBar];  
  11.   
  12. //search Button clicked....  
  13. - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar                     // called when keyboard search button pressed  
  14. {  
  15.     NSLog( @"%s,%d" , __FUNCTION__ , __LINE__ );  
  16.     [searchBar resignFirstResponder];  
  17. }  
  18. //cancel button clicked...  
  19. - (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar                    // called when cancel button pressed  
  20. {  
  21.     NSLog( @"%s,%d" , __FUNCTION__ , __LINE__ );  
  22.       
  23.     [searchBar resignFirstResponder];  
  24.       
  25. }  
0 0