搜索框UISearchBar

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搜索框UISearchBar相关的知识,希望对你有一定的参考价值。

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(@"改变了");

}

 

以上是关于搜索框UISearchBar的主要内容,如果未能解决你的问题,请参考以下文章