这是一段代码,将为您提供有关设备的所有信息
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
NSLog(@"name: %@", [[UIDevice currentDevice] name]);
NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
NSLog(@"model: %@", [[UIDevice currentDevice] model]);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);
您可以在此处获取版本号。
但我建议您检查手机是否支持邮件编辑器、短信 喜欢
类 messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {
// Check whether the current device is configured for sending SMS messages
if ([messageClass canSendText])
{
MFMessageComposeViewController *msgpicker = [[MFMessageComposeViewController alloc] init];
msgpicker.messageComposeDelegate = self;
msgpicker.recipients = [NSArray arrayWithObject:[self.productInfoArray valueForKey:@"Phone"]]; // your recipient number or self for testing
msgpicker.body = @"test from OS4";
NSLog(@"chat view array %@",[self.productInfoArray valueForKey:@"Phone"]);
[self presentModalViewController:msgpicker animated:YES];
[msgpicker release];
NSLog(@"SMS fired");
}
else { NSLog(@"chat view array %@",[self.productInfoArray valueForKey:@"Phone"]);
NSLog(@"Device not configured to send SMS.") ;
UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Status" message:@"Device not configured to send SMS." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"cancel",nil];
[alert show];
[alert release];
}
}
这将有助于解决您的问题。 快乐编码 干杯......
UIDevice 类有一个 systemVersion 属性,您可以使用它来获取操作系统版本。这将返回版本值,例如 3.1 或 4.2。我猜您可以使用它来确定对短信功能的访问。
@property (nonatomic, readonly, retain) NSString *systemVersion
查看参考资料以获取更多信息 > http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html
我想你可以使用
NSClassFromString(@"MFMessageComposeViewController")
来查看该课程是否可用。
(警告:您无法通过这种方式检查
UIGestureRecognizer
,因为 Apple 使用了同名的私有类。MFMessageComposeViewController
也可能如此。)