使用搜索栏时,无法使表格视图处于非活动状态.苹果手机 [英] Can't make table view inactive when search bar is in use. iPhone

查看:64
本文介绍了使用搜索栏时,无法使表格视图处于非活动状态.苹果手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格视图,上面有一个搜索栏,当按下搜索栏时,我希望该表格视图变为非活动状态.所以我有这种方法:

I have a table view with a search bar above it, and when the search bar is pressed I want the table view to become inactive. So I have this method:

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
    self.tableView.userInteractionEnabled = NO;
}

,具有相同类的是UISearchBarDelegate.由于某种原因,它不会禁用表视图.有什么想法吗?让我知道是否还有其他需要帮助的代码.谢谢.

with the same class being the UISearchBarDelegate. For some reason though it doesn't disable the table view. Any thoughts? Let me know if there's any other pieces of code needed to help. Thanks.

推荐答案

不知道为什么userInteractionEnabled不会使您的 UITableView 处于非活动状态,但是我可以建议一种替代方法.

Not sure why userInteractionEnabled is not making your UITableView inactive, but I can suggest an alternative approach.

我最近将项目从手动添加 UISearchBar 作为 UITableView 的子视图移到了使用

I recently moved a project over from manually adding a UISearchBar as a subview of my UITableView to using a UISearchDisplayController. I can definitely recommend doing it this way. The SearchDisplayController will animate in a alpha blended view behind the search bar which prevents interaction with the underlying table view, which would avoid the problem you are having.

更新:

这可能与您添加UISearchDisplayController的方式有关.您的视图层次结构看起来像这样吗?

This might be something to do with the way you are adding your UISearchDisplayController. Does your view hierarchy look like this?

这篇关于使用搜索栏时,无法使表格视图处于非活动状态.苹果手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆