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

}

 

posted on 2016-06-19 11:26  小艾的博客  阅读(151)  评论(0编辑  收藏  举报

导航