我用的是UISearchDisplayController。
当用户在表格中选择一行时,我想隐藏搜索栏。
下面是我的尝试:
- (void)displaySearchBar:(BOOL)show {
[UIView animateWithDuration:0.15
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
[m_searchDisplayController.searchBar setHidden:!show];
[m_categoriesView.categoriesTable setContentInset:show ?
UIEdgeInsetsMake(0,0,0,0) : UIEdgeInsetsMake(-CGRectGetHeight(m_searchDisplayController.searchBar.frame),0,0,0)];
if( show ) {
[m_categoriesView.categoriesTable setContentOffset:CGPointZero];
}
}
completion:NULL];
}除了用户旋转设备之外,所有设备都工作正常。搜索栏是隐藏的,但我在桌面上留出了一个黑色空间。
有人有线索吗?
诚挚的问候,
马丁
发布于 2011-11-01 09:23:22
我将猜测您的表视图没有正确调整大小,因此当搜索栏被移除时,您将看到父视图的任何背景。
发布于 2012-05-20 23:17:57
你为什么不用
[self.searchDisplayController setActive:NO animated:YES];而不是所有的代码。这也将删除键盘
https://stackoverflow.com/questions/7961509
复制相似问题