Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么为TARGET_OS_IPHONE定义的NSTextAlignment枚举不同?_Ios_Uikit - Fatal编程技术网

Ios 为什么为TARGET_OS_IPHONE定义的NSTextAlignment枚举不同?

Ios 为什么为TARGET_OS_IPHONE定义的NSTextAlignment枚举不同?,ios,uikit,Ios,Uikit,我只是在看UIKit中的NSText.h,下面的代码让我觉得很不寻常 /* Values for NSTextAlignment */ typedef NS_ENUM(NSInteger, NSTextAlignment) { NSTextAlignmentLeft = 0, // Visually left aligned #if TARGET_OS_IPHONE NSTextAlignmentCenter = 1, // Visually cent

我只是在看UIKit中的NSText.h,下面的代码让我觉得很不寻常

/* Values for NSTextAlignment */
typedef NS_ENUM(NSInteger, NSTextAlignment) {
    NSTextAlignmentLeft      = 0,    // Visually left aligned
#if TARGET_OS_IPHONE
    NSTextAlignmentCenter    = 1,    // Visually centered
    NSTextAlignmentRight     = 2,    // Visually right aligned
#else /* !TARGET_OS_IPHONE */
    NSTextAlignmentRight     = 1,    // Visually right aligned
    NSTextAlignmentCenter    = 2,    // Visually centered
#endif
    NSTextAlignmentJustified = 3,    // Fully-justified. The last line in a paragraph is natural-aligned.
    NSTextAlignmentNatural   = 4,    // Indicates the default alignment for script
} NS_ENUM_AVAILABLE_IOS(6_0);

为什么TARGET_OS_IPHONE的NSTextAlignmentRight和NSTextAlignmentCenter的值与not不同?

在iOS 6之前,iOS没有
NSTextAlignment
。使用的iOS
UITextAlignment
Center
值为
1
Right
值为
2

然后在iOS 6中,添加了
NSTextAlignment
。为了保持向后兼容性,
NSTextAlignmentCenter
的值与
UITextAlignmentCenter
的值相同。右侧的
相同

iOS上的
NSTextAlignment
enum与弃用的
uitextlalignment
匹配比与OS X中的值相同更重要

iOS上的
UITextAlignment
和OS X上的
NSTextAlignment
之间的最初区别可能只是一个简单的疏忽。但这只是一个简单的猜测