Catalogue [-]
- First, the judgment equipment
- Second, determine the network connection status
- Third, the device does not show the solution
First, the judgment equipment
02 |
return [UIDevice currentDevice].name; |
04 |
//设备型号,只可得到是何设备,无法得到是第几代设备 |
05 |
return [UIDevice currentDevice].model; |
08 |
return [UIDevice currentDevice].systemVersion; |
11 |
return [UIDevice currentDevice].systemName; |
02 |
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) |
05 |
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
08 |
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"]) |
11 |
#define IS_IPHONE_5_SCREEN [[UIScreen mainScreen] bounds].size.height >= 568.0f && [[UIScreen mainScreen] bounds].size.height < 1024.0f |
Second, determine the network connection status
1, import systemconfiguration.framework, and #import<systemconfiguration/scnetworkreachability.h>
2. Determine if the equipment is networked
01 |
+ ( BOOL )connectedToNetwork{ |
03 |
//创建零地址,0.0.0.0的地址表示查询本机的网络连接状态 |
05 |
struct sockaddr_storage zeroAddress; |
07 |
bzero(&zeroAddress, sizeof (zeroAddress)); |
08 |
zeroAddress.ss_len = sizeof (zeroAddress); |
09 |
zeroAddress.ss_family = AF_INET; |
11 |
// Recover reachability flags |
12 |
SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, ( struct sockaddr *)&zeroAddress); |
13 |
SCNetworkReachabilityFlags flags; |
16 |
BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags); |
17 |
CFRelease(defaultRouteReachability); |
19 |
//如果不能获取连接标志,则不能连接网络,直接返回 |
26 |
BOOL isReachable = flags & kSCNetworkFlagsReachable; |
27 |
BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired; |
28 |
return (isReachable&&!needsConnection) ? YES : NO; |
Third, the device does not show the solution
PS: If the device is plugged in, but Xcode does not display the current device, it is still the status of iOS device, as shown in
Resolution Steps
1. Click on the organizer->devices in the upper right corner of Xcode to see if your device is green, if it is yellow or no lights, it means the device is not connected, please re-insert it again
2. If the device is connected, but still does not display, the system version does not match, if the device is a ios5 system, then Xcode iOS Deployment Target must be 5.0 or above, Xcode can distinguish this device
Select Targets->summary-deployment Target to modify the iOS version number (assuming set to 6.1)
If still not recognized, the version number is also modified to 6.1 under Project->info->ios Deployment target