最近在把一个iOS5.0的老项目升级到iOS7.1,发现在iOS6.0的时候,就有一些函数和枚举值被废弃。
那么在做版本兼容的时候,我们可以使用respondsToSelector这个函数,具体怎么使用就不多说了。
iOS6.0以下版本的函数、枚举(红色表示iOS6.0以上可用)
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0);
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion NS_AVAILABLE_IOS(5_0);
- (void)dismissModalViewControllerAnimated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0);
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion NS_AVAILABLE_IOS(5_0);
typedef NS_ENUM(NSInteger, UILineBreakMode) {
UILineBreakModeWordWrap = 0, // Wrap at word boundaries
UILineBreakModeCharacterWrap, // Wrap at character boundaries
UILineBreakModeClip, // Simply clip when it hits the end of the rect
UILineBreakModeHeadTruncation, // Truncate at head of line: "…wxyz". Will truncate multiline text on first line
UILineBreakModeTailTruncation, // Truncate at tail of line: "abcd…". Will truncate multiline text on last line
UILineBreakModeMiddleTruncation, // Truncate middle of line: "ab…yz". Will truncate multiline text in the middle
} NS_DEPRECATED_IOS(2_0,6_0);
typedef NS_ENUM(NSInteger, NSLineBreakMode) { /* What to do with long lines */
NSLineBreakByWordWrapping = 0, /* Wrap at word boundaries, default */
NSLineBreakByCharWrapping, /* Wrap at character boundaries */
NSLineBreakByClipping, /* Simply clip */
NSLineBreakByTruncatingHead, /* Truncate at head of line: "…wxyz" */
NSLineBreakByTruncatingTail, /* Truncate at tail of line: "abcd…" */
NSLineBreakByTruncatingMiddle /* Truncate middle of line: "ab…yz" */
} NS_ENUM_AVAILABLE_IOS(6_0);
// Deprecated: use NSTextAlignment enum in UIKit/NSText.h
typedef NS_ENUM(NSInteger, UITextAlignment) {
UITextAlignmentLeft = 0,
UITextAlignmentCenter,
UITextAlignmentRight, // could add justified in future
} NS_DEPRECATED_IOS(2_0,6_0);
/* 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);