I have one tableview and each cell contains one button. It\'s working pretty well all iOS versions but 7. I don\'t know what\'s going on. The cell is constructed in one xib
The solution to this problem is;
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
cell.bringSubviewToFront(cell.YOUR_UIView)
}
This works for me.
I faced a similar issue on both UITableViewCell and UICollectionViewCell. Few steps to follow:
In short, TableView/CollectionView cells cannot take actionable subviews (UIButton, UISegmentedControl) that are auto-layout enabled. If you have a need for it, either disable auto-layouts and provide frames (or) put them inside a container view (Container view should have auto layout disabled) and add the actionable views (with auto layout) as subviews to the container view.
I had subclassed UITableViewCell and solved it by changing this code:
addSubview(myButton)
to this:
contentView.addSubview(myButton)
in my UITableViewCell subclass.
In my case, everything that I would like the user to interact with is outside of the ContentView. Also I do not want the cell to be highlighted when it is selected.
All labels (Name, Categories, etc.) are immediately under "Content View". The WebsiteButton is not under "Content View", but it is under "Local Directory Table Cell".
In my tableViewController method tableView:cellForRowAtIndexPath: I have the following code: cell.contentView.userInteractionEnabled = NO;
That is all and the user is able to interact with the button. I do NOT use [cell bringSubviewToFront:cell.websiteButton];
Calling [cell bringSubviewToFront:button]
after loading the cell from nib solved this for me.
I have been get the same problem. The reason is
self.contentView.Frame.size.height
is always 44.
There is a suggestion you can set your self.contentView.Frame
to self.frame
at the overwrite method - (void)layoutSubviews
the problem will be solved