不推荐使用UILineBreakModeWordWrap [英] UILineBreakModeWordWrap is deprecated

查看:146
本文介绍了不推荐使用UILineBreakModeWordWrap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

CGSize s = [string sizeWithFont:[UIFont systemFontOfSize:20]
               constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, CGFLOAT_MAX) // - 40 For cell padding
                   lineBreakMode:UILineBreakModeWordWrap];

我收到警告,iOS 6中不推荐使用UILinebBreakModeWordWrap。

I get a warning that UILinebBreakModeWordWrap is deprecated in iOS 6.

推荐答案

您需要在iOS 6中使用 NSLineBreakByWordWrapping

You need to use NSLineBreakByWordWrapping in iOS 6

对于您的代码,请尝试以下操作:

For your code try this:

NSString *string = @"bla";

CGSize s = [string sizeWithFont:[UIFont systemFontOfSize:20]
              constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, CGFLOAT_MAX) // - 40 For cell padding
                  lineBreakMode:NSLineBreakByWordWrapping];

标签上的示例为:

[label setLineBreakMode:NSLineBreakByWordWrapping];

而不是

label.lineBreakMode = UILineBreakModeWordWrap;

这篇关于不推荐使用UILineBreakModeWordWrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆