问题描述
我现在使用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.
所有可能的合理文本解决方案都在此还
查看和。
All possible solutions to justified text are given at this SO link alsohave a look at this page and iOS6 prerelease Documentation.
这篇关于NSTextAlignmentJustified到iOS上的UILable textAligment将崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!