开发者

How can I hide the UITableView that UISearchBar created?

开发者 https://www.devze.com 2022-12-14 08:38 出处:网络
In my iPhone application I have a search bar and search display controller. When the user types something in the search box, the table view loads and is now visible. When a user clicks on a row, I wou

In my iPhone application I have a search bar and search display controller. When the user types something in the search box, the table view loads and is now visible. When a user clicks on a row, I would like to get rid of the tableVi开发者_开发知识库ew and go back to the view where the user originally clicked the search bar. I have searched all over the documentation, I cannot find how to do this anywhere. I have tried [tableView setHidden:YES]; but when the user clicks on the search bar again the tableView never returns.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

Please can someone point me in the right direction.


you can try smth like

[mySerchDisplayController setActive:NO animated:YES];


Why don't you just remove the table view from the View Hierarchy?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   [tableView deselectRowAtIndexPath:indexPath animated:NO];

   // update your model based on the current selection

   [tableView removeFromSuperview];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号