将我的 xcode 4.5 更新到 4.6 后....
lblMyLable.lineBreakMode = UILineBreakModeWordWrap;
textFieldRounded1.textAlignment = UITextAlignmentLeft;
停止工作并显示不兼容的错误...它们在 xcode 更新前 2 天之前工作良好。
P.S:- lblMyLable 是一个 UILabel & textFieldRounded1 是一个 UITextField
我使用的是6.1 IOS sdk
最佳答案
在 iOS 6 中,您需要使用 NSLineBreakByWordWrapping。 而不是:
lblMyLable.lineBreakMode = UILineBreakModeWordWrap;
textFieldRounded1.textAlignment = UITextAlignmentLeft;
用途:
lblMyLable.lineBreakMode = NSLineBreakByWordWrapping;
textFieldRounded1.textAlignment = NSTextAlignmentLeft;
详细信息
lineBreakMode
The technique to use for wrapping and truncating the label’s text.
@property(nonatomic) NSLineBreakMode lineBreakMode;
Discussion
If you are using styled text in iOS 6 or later, assigning a new value to this property causes the line break mode to be applied to the entirety of the string in the attributedText property. If you want to apply the line break mode to only a portion of the text, create a new attributed string with the desired style information and associate it with the label. If you are not using styled text, this property applies to the entire text string in the text property.
This property is in effect both during normal drawing and in cases where the font size must be reduced to fit the label’s text in its bounding box. This property is set to NSLineBreakByTruncatingTail by default.
Important: If this property is set to a value that causes text to wrap to another line, it is a programmer error to set either the adjustsFontSizeToFitWidth or adjustsLetterSpacingToFitWidth property to YES.
Special Considerations
In iOS 5 and earlier, the type of this property was UILineBreakMode. Availability
Available in iOS 2.0 and later.
NSLineBreakMode
These constants specify what happens when a line is too long for its container.
enum { NSLineBreakByWordWrapping = 0, NSLineBreakByCharWrapping, NSLineBreakByClipping, NSLineBreakByTruncatingHead, NSLineBreakByTruncatingTail, NSLineBreakByTruncatingMiddle }; typedef NSUInteger NSLineBreakMo
Constants
NSLineBreakByWordWrapping
Wrapping occurs at word boundaries, unless the word itself doesn’t fit on a single line. Available in iOS 6.0 and later. Declared in NSParagraphStyle.h.
NSLineBreakByCharWrapping
Wrapping occurs before the first character that doesn’t fit. Available in iOS 6.0 and later. Declared in NSParagraphStyle.h.
NSLineBreakByClipping
Lines are simply not drawn past the edge of the text container. Available in iOS 6.0 and later. Declared in NSParagraphStyle.h.
NSLineBreakByTruncatingHead
The line is displayed so that the end fits in the container and the missing text at the beginning of the line is indicated by an
ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.
Available in iOS 6.0 and later. Declared in NSParagraphStyle.h.
NSLineBreakByTruncatingTail
The line is displayed so that the beginning fits in the container and the missing text at the end of the line is indicated by an
ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.
Available in iOS 6.0 and later. Declared in NSParagraphStyle.h.
NSLineBreakByTruncatingMiddle
The line is displayed so that the beginning and end fit in the container and the missing text in the middle is indicated by an
ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.
Available in iOS 6.0 and later. Declared in NSParagraphStyle.h.
请查看UILabel Class更多细节。 另请检查UITextField Class有关 NSTextAlignment 值和详细信息。
关于iphone - 从不兼容类型分配给 'NSLineBreakMode',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14753579/