gpt4 book ai didi

ios - 大小与字体 : in iOS 7

转载 作者:行者123 更新时间:2023-11-28 19:07:27 26 4
gpt4 key购买 nike

我收到一条警告:“‘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;
}

最佳答案

备选方案是:

- (NSSize)sizeWithAttributes:(NSDictionary *)attributes

在你的情况下:

[string sizeWithAttributes:@{NSFontAttributeName:[UIFont fontwithName:@"SeroCompPro-Light" size:14]}];

关于ios - 大小与字体 : in iOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19045138/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com