I'd like to make a custom UITableViewCell height using (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
.
I'm trying to get the height of the UITableViewCell
by multiplying the number of lines in textLabel
by the height of each line and then adding 10.0f
for the subtitle. I am using the following code and getting exc_bad_access()
. Why?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return ([[[tableView cellForRowAtIndexPath:indexPath] textLabel] numberOfLines] * [[[[tableView cellForRowAtIndexPath:indexPath] textLabel] font] lineHeight]) + 10.0;
//return kRowHeightiPod; //A constant value for a sanity check
}