[英]How do I determine whether curreltly connected wifi is secure or not in iPhone or iPad
[英]How do I determine whether the current device is an iPhone or iPad?
在我的通用应用程序中,我需要检查当前设备是iPad还是iPhone。 我该如何以编程方式执行此操作? 我打算把代码放在我的viewDidLoad中。
检查平台上是否有UISplitViewController
类可用,如果是,请确保它是使用Apple宏的iPad(注意UIUserInterfaceIdiomPad
常量仅在iOS 3.2及更高版本上可用)。
if (NSClassFromString(@"UISplitViewController") != nil && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//currentDeviceType = iPad;
}
else {
//currentDeviceType = iPhone;
}
我在所有应用中使用这个简单的功能:
#import "isPad.h"
BOOL isPad () {
static BOOL isPad;
static BOOL used = NO;
if (used)
return isPad;
used = YES;
NSRange range = [[[UIDevice currentDevice] model] rangeOfString:@"iPad"];
isPad = range.location != NSNotFound;
return isPad;
}
try this.. this will help you.
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPod touch"]||[deviceType isEqualToString:@"iPhone"]||[deviceType isEqualToString:@"iPad"]){
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// Statements
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
// Statements
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.