NSTextAlignmentJustified到iOS上的UILable textAligment将崩溃 [英] NSTextAlignmentJustified to UILable textAligment on iOS6 will crash

查看:867
本文介绍了NSTextAlignmentJustified到iOS上的UILable textAligment将崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在使用Xcode4.5和iOS6,iOS6更改了UILable的textAlignment,

I am use Xcode4.5 and iOS6 now, the iOS6 have change the UILable's textAlignment,

label.textAlignment = NSTextAlignmentJustified;

使用ios6 SDK,iPhone 6.0 Simulator上的代码会崩溃。但不会在带有iOS6 SDK的iPhone 5.0模拟器上崩溃。

The code will crash on iPhone 6.0 Simulator with ios6 SDK. but not crash on iPhone 5.0 Simulator with iOS6 SDK.

iOS6支持NSTextAlignmentJustified,但为什么会崩溃?

The iOS6 support NSTextAlignmentJustified, but why will crash?

推荐答案

编辑1:

使用 NSAttributedString 我们可以证明文本的合理性。

Using NSAttributedString we can justify text.

NSMutableParagraphStyle *paragraphStyles = [[NSMutableParagraphStyle alloc] init];
paragraphStyles.alignment                = NSTextAlignmentJustified;
paragraphStyles.firstLineHeadIndent      = 0.05;    // Very IMP

NSString *stringTojustify                = @"We are what our thoughts have made us; so take care about what you think. Words are secondary. Thoughts live; they travel far.";
NSDictionary *attributes                 = @{NSParagraphStyleAttributeName: paragraphStyles};
NSAttributedString *attributedString     = [[NSAttributedString alloc] initWithString:stringTojustify attributes:attributes];

self.lblQuote.attributedText             = attributedString;
self.lblQuote.numberOfLines              = 0;
[self.lblQuote sizeToFit];





弃用 UITextAlignmentJustify ,在iOS 6下不再可用。

Deprecation of UITextAlignmentJustify, not available anymore under iOS 6.

所有可能的合理文本解决方案都在此 SO链接
查看此页面 iOS6预发布文档

All possible solutions to justified text are given at this SO link also have a look at this page and iOS6 prerelease Documentation.

这篇关于NSTextAlignmentJustified到iOS上的UILable textAligment将崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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