UITutView在UITableView头中忽略大多数触摸 [英] UIButton in a UITableView header ignores most touches
问题描述
我有一个按钮,我添加为一个表视图的tableHeaderView的子视图。按钮看起来很好,并且点击并持续它间歇地工作 - 大部分,但是,它没有反应。我试过添加它作为表本身的子视图;效果大致相同。我认为问题可能是与滚动视图的触摸拦截,但禁用在表上滚动也没有任何效果。
我做错了什么?有没有人遇到过这个?
编辑 - 澄清,我说的是一个分组表样式表中的主表头,而不是节头;
我有同样的问题。在我的情况下,我有一个容器视图实例化在IB(应用为表视图头在代码中),UIImageView占据该容器的整个框架。
结果我需要在IB中设置大小调整如下:
集装箱视图:外部锚点全部开启,内部调整大小 - 全部关闭
子图片视图:所有支柱(内部和外部) b
$ b
我有几个不同的表视图,都使用头视图。一些会正确地响应触摸事件,一些是片状的。这解决了我的问题
I've got a button that I'm adding as a subview of a table view's tableHeaderView. The button appears fine, and tap-and-holding on it works intermittently - for the most part, though, it's unresponsive. I've tried adding it as a subview of the table itself; the effect is about the same. I thought the problem might be with the scroll view's touch interception, but disabling scrolling on the table has no effect either.
Am I doing something wrong? Has anyone else encountered this?
edit - to clarify, I'm talking about the main table header, not a section header, in a grouped-style table; think basically modeled after the "Contact" screen.
I had the same problem. In my case I had a container view instantiated in IB (that was applied as the table view header in code), with a UIImageView occupying the entire frame of that container. The misbehaving button resided in the image view.
Turns out I needed to have sizing struts in IB set as follows...
Container View: exterior anchors all on, interior resizing - all off
Sub Image View: all struts on (interior and exterior)
I had several different table views, all using header views. Some would respond to touch events correctly, some were flaky. This solved my problem
这篇关于UITutView在UITableView头中忽略大多数触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!