UISearchDisplayController的全屏背景拦截了iOS 7中的触摸事件 [英] UISearchDisplayController's full-screen background intercepts touch events in iOS 7

查看:94
本文介绍了UISearchDisplayController的全屏背景拦截了iOS 7中的触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不占用整个屏幕的 UITableview 截图)。在iOS 6中一切正常。但在iOS 7中,当用户搜索时,搜索结果表占用整个视图(屏幕截图)。

I have a UITableview that doesn't take up the whole screen (screenshot). Everything worked fine in iOS 6. But in iOS 7, when the user searches, the search result table takes up the whole view (screenshot).

要解决此问题,我尝试按照这个答案。外观现在是正确的(截图),但现在<当显示搜索结果表时,左上角的按钮不会收到点击事件。

To fix this, I tried setting the frame manually as described in this answer. The appearance is now correct (screenshot), but now the "<" button in the top left doesn't receive tap events when the search results table is displayed.

似乎 searchResultsTableView 正在添加一个拦截触摸事件的全屏背景视图。为了证明这一点,我将此代码添加到 didShowSearchResultsTableView

It seems the searchResultsTableView is adding a full-screen background view that is intercepting touch events. To prove this, I added this code to didShowSearchResultsTableView:

   controller.searchResultsTableView.superview.backgroundColor = [UIColor blueColor];`

截图证实了我的假设。

如何修复此问题以允许<按钮接收点击事件?
我想避免修改 controller.searchResultsTableView.superview ,以便我的更改不会在iOS的未来版本中中断。

How can I fix this to allow the "<" button to receive tap events? I want to avoid modifying controller.searchResultsTableView.superview so that my change doesn't break in future versions of iOS.

iOS 7中的哪些变化导致这种行为开始发生?

And what change in iOS 7 caused this behavior to start happening?

推荐答案

我还在寻找一个更好的解决方案,但目前我的解决方案是在viewControllers viewDidLayoutSubviews 告诉你的视图移到前面。代码看起来像这样。

I am still searching for a better solution, but currently my solution is in the viewControllers viewDidLayoutSubviews tell your view to move to front. The code would look something like this.

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    [self.view bringSubviewToFront:self.navigationBar];
}

这篇关于UISearchDisplayController的全屏背景拦截了iOS 7中的触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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