7.0使用UISearchDisplayController的搜索的返回结果 让TableView的Frame变化

Ylang 发布于 2014/05/15 11:19
阅读 1K+
收藏 0
iOS
 
搜索结果 


出现这种状态是因为键盘的frame导致的UITableView的frame发生变化

解决办法

- (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView {

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];

}



- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView {

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil];

}



- (void) keyboardWillHide {

    UITableView *tableView = [[self searchDisplayController] searchResultsTableView];

    [tableView setContentInset:UIEdgeInsetsZero];

    [tableView setScrollIndicatorInsets:UIEdgeInsetsZero];

}

加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部