iOS9 - UITableViewCellContentView is covering up Controls inside Cell

孤人 提交于 2019-12-02 23:03:17
FranticRock

After more investigation and searching, i found my solution here: Button in UITableViewCell not responding under ios 7

What fixed it for me was: cell.contentView.userInteractionEnabled = NO;

This prevents the cell content view from taking over the touch events, even though it's on top of the other views.

This issue was not only happening on iOS9, but on iOS7 as well. In iOS8, the Content view was behind the controls.

Problem can be in .xib file for your cell. When you create cell in separate .xib, be sure to drag UITableViewCell on canvas, not UIView.

I had this problem when I was reusing a cell as a .xib. I didn't realise but when I first created the xib the default view that it created was in fact a UIView and not a UITableViewCell. It seems that at some stage UIKit adds the content view on top of my other elements and therefore interrupts certain events (e.g. touch events).

I resolved this by opening my xib file and dragging a UITableViewCell onto the canvas and copying my UI elements from the old view to the new cell.

Afterwards, additional settings also became available in the attributes inspector that matched those for a UITableViewCell.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!