0

How can self.frame and self.contentView.frame in:

override init(style: UITableViewCellStyle, reuseIdentifier: String) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    // Initialization code here        
}

.. of a UITableViewCell subclass contain 44px in height when it is shown as 200x in simulator and device?

Update:

For detailed explanation of why this happens in iOS8: https://stackoverflow.com/a/25884832/1178924

Community
  • 1
  • 1
AlexanderN
  • 2,610
  • 1
  • 26
  • 42

2 Answers2

2

A few things:

Presumably you're setting the tableView delegate to the class that you implement heightForRowAtIndexPath in.

If your UITableView is defined inside of an interface builder file, make sure that you set the value for "row height" in the "Size Inspector" to the height of your cell (200).

Inside of the init method that you're overriding above, frames may not yet be set, hence getting a default value. You could check the layoutSubviews or updateConstraints methods for proper frame values.

Alfie Hanssen
  • 16,964
  • 12
  • 68
  • 74
1

44px is iOS' default table cell height. If you want to specify the height for a custom tableView cell you have to override tableView.heightForRowAtIndexPath

zisoft
  • 22,770
  • 10
  • 62
  • 73
  • Sorry, I have already done that or it wouldn't be 200x in the simulator like mentioned above. The problem is that whatever I return in tableView.heightForRowAtIndexPath isn't reflected in the UITableViewCell subclass init. – AlexanderN Sep 23 '14 at 15:15