UIButton in a UITableView header ignores most touches

前端 未结 9 2576
盖世英雄少女心
盖世英雄少女心 2020-12-28 18:58

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 p

9条回答
  •  情书的邮戳
    2020-12-28 19:10

    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

提交回复
热议问题