I have a problem regarding incompatibility of ios5 vs ios6
While I was working on my project with ios5
label.textAlignment = UITextAlignmentCenter;
then updated to ios6
label.textAlignment = NSLineBreakByTruncatingTail;
Once I run my code on the device which ios5 installed, that give me error.
I am about to upload my app to appstore, however I want my app also supports ios5 as well. How I am going to handle both ios5 and ios6!
Thanks in advance!
The acceptable values for NSTextAlignment are:
Of those any of the first three will work equally under iOS 5 and 6.
NSLineBreakByTruncatingTailisn’t really a valid type of text alignment though it’ll look likeNSTextAlignmentNaturalat runtime because of the way the C enums line up.So you’ll need either to switch to
NSTextAlignmentLeftacross the board or to do a functionality check. Thankfully the change in text alignment type is in support of the new ability to push attributed strings toUILabel(and elsewhere) so that gives you something to hang off.E.g.
Though the else is technically redundant because
NSTextAlignmentLeftis the default value.