标签:
1\初始化
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(10, 20, 200, 30)];
[self.view addSubview:searchBar];
searchBar.delegate = self;
2\实现代理方法
-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
NSLog(@"开始编辑");
[self presentViewController:[[redViewController alloc] init] animated:YES completion:nil];
return YES;
}
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
NSLog(@"改变了");
}
标签:
原文地址:http://www.cnblogs.com/making/p/5597711.html