问题
I was trying to use estimatedHeightForRowAtIndexPath
for dynamic cell height with AutoLayout and working as expected in iOS8 but crush in iOS7.1 by saying this:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyProject.ViewController tableView:heightForRowAtIndexPath:]: unrecognized selector sent to instance 0x79e91350'
If I define heightForRowAtIndexPath
, error go away but cell won't auto size itself. Any idea?
Update: It's indeed available in iOS 7.0, right?
回答1:
try :
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1 ){
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 206;
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1 {
return UITableViewAutomaticDimension
} else {return 206}
}
来源:https://stackoverflow.com/questions/28958707/ios-7-1-crash-if-heightforrowatindexpath-is-not-declared