【发布时间】:2013-09-27 07:30:37
【问题描述】:
我收到警告:“'sizeWithFont:constrainedToSize:lineBreakMode:' 已弃用:iOS 7.0 中首次弃用” 任何人都可以建议我使用这种方法的替代方法吗?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Calculate height based on cell content — cell content will stretch appropriately when the height is set
Post *post = self.articleComments[indexPath.row];
CGFloat width = tableView.frame.size.width - 71 - 15; // Width of comment text area
UIFont *commentFont = [UIFont fontWithName:@"SeroCompPro-Light" size:14];
CGFloat commentTextHeight = [post.text sizeWithFont:commentFont constrainedToSize:CGSizeMake(width, 10000) lineBreakMode:NSLineBreakByWordWrapping].height;
return commentTextHeight + 31 + 37;
}
【问题讨论】:
-
是的,但那是 CGRect ,我需要 CGFloat 。
-
再次是 CGRect 我需要 CGfloat ,CGFloat commentTextHeight = [post.text sizeWithFont:commentFont constrainedToSize:CGSizeMake(width, 10000) lineBreakMode:NSLineBreakByWordWrapping].height;
-
这是我收到警告的行,我的输出显示不正确。
标签: ios objective-c ios7