我使用此代码来支持多个版本的iOS(3.0,4.0,5.0),我的应用程序..
把这个顶部(连同进口)
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
然后,如果有一些操作系统特定的功能,像这样使用它们(我使用AlertView作为示例,在iOS5之前,UIAlertView不支持自定义的textView,所以我有自己的自定义AlertView在iOS5中,这种黑客行不通,我有使用UIAlertView,因为它支持自定义textViews):
if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
TextAlertView *alert = [[TextAlertView alloc] initWithTitle:@"xxxYYzz"
message:@""
delegate:self cancelButtonTitle:@"Add"
otherButtonTitles:@"Cancel", nil];
alert.textField.keyboardType = UIKeyboardTypeDefault;
alert.tag = 1;
self.recipeNameTextField = alert.textField;
[alert show];
[alert release];
}
else {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"xxYYzz"
message:@""
delegate:self cancelButtonTitle:@"Add"
otherButtonTitles:@"Cancel", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
self.recipeNameTextField = [alert textFieldAtIndex:0];
[alert show];
[alert release];
}
希望它有帮助
谢谢安舒。但这就是我的意思,关于开销或特征歧视,我不想要,因为没有为单独版本计划的特殊功能。 – mia 2012-01-06 10:38:11