ios - I want my application to identify iPhone models because I'm not using autolayout -


i wrote code in following way

#define isiphone6 ( [[uiscreen mainscreen] bounds].size.height == 667)?true:false #define isiphone5  ([[uiscreen mainscreen] bounds].size.height == 568)?true:false  uistoryboard *mainstoryboard = nil;   printf("\ndetected resolution : %d x %d\n\n",(int)[[uiscreen mainscreen] nativebounds].size.width,(int)[[uiscreen mainscreen] nativebounds].size.height);   if (isiphone5) {     mainstoryboard = [uistoryboard storyboardwithname:@"mainiphone5" bundle:nil];;     // iphone 4 inch }  else  if (isiphone6) {     mainstoryboard = [uistoryboard storyboardwithname:@"mainiphone6" bundle:nil];;     // iphone 4 inch }  else {     mainstoryboard = [uistoryboard storyboardwithname:@"main" bundle:nil];     //iphone  3.5 inch }  self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; self.window.rootviewcontroller = [mainstoryboard instantiateinitialviewcontroller]; [self.window makekeyandvisible]; 

but loop iphone6 not working , loops working 3.5 , 4inch. here loop jumping iphone5, iphone4 not 6.

see class

https://github.com/froztbytes/uidevicehardware

or create class

 #import <foundation/foundation.h>   @interface uidevicehardware : nsobject      + (nsstring *) platform;      + (nsstring *) platformstring;  @end        #import "uidevicehardware.h"     #include <sys/types.h>     #include <sys/sysctl.h>      @implementation uidevicehardware      + (nsstring *) platform{         size_t size;         sysctlbyname("hw.machine", null, &size, null, 0);         char *machine = malloc(size);         sysctlbyname("hw.machine", machine, &size, null, 0);         nsstring *platform = [nsstring stringwithutf8string:machine];         free(machine);         return platform;     }      + (nsstring *) platformstring{         nsstring *platform = [self platform];         if ([platform isequaltostring:@"iphone1,1"])    return @"iphone 1g";         if ([platform isequaltostring:@"iphone1,2"])    return @"iphone 3g";         if ([platform isequaltostring:@"iphone2,1"])    return @"iphone 3gs";         if ([platform isequaltostring:@"iphone3,1"])    return @"iphone 4 (gsm)";         if ([platform isequaltostring:@"iphone3,3"])    return @"iphone 4 (cdma)";         if ([platform isequaltostring:@"iphone4,1"])    return @"iphone 4s";         if ([platform isequaltostring:@"iphone5,1"])    return @"iphone 5 (gsm)";         if ([platform isequaltostring:@"iphone5,2"])    return @"iphone 5 (cdma)";         if ([platform isequaltostring:@"iphone5,3"])    return @"iphone 5c";         if ([platform isequaltostring:@"iphone5,4"])    return @"iphone 5c";         if ([platform isequaltostring:@"iphone6,1"])    return @"iphone 5s";         if ([platform isequaltostring:@"iphone6,2"])    return @"iphone 5s";         if ([platform isequaltostring:@"iphone7,1"])    return @"iphone 6 plus";         if ([platform isequaltostring:@"iphone7,2"])    return @"iphone 6";          if ([platform isequaltostring:@"ipod1,1"])      return @"ipod touch 1g";         if ([platform isequaltostring:@"ipod2,1"])      return @"ipod touch 2g";         if ([platform isequaltostring:@"ipod3,1"])      return @"ipod touch 3g";         if ([platform isequaltostring:@"ipod4,1"])      return @"ipod touch 4g";         if ([platform isequaltostring:@"ipod5,1"])      return @"ipod touch 5g";          if ([platform isequaltostring:@"ipad1,1"])      return @"ipad";         if ([platform isequaltostring:@"ipad2,1"])      return @"ipad 2 (wifi)";         if ([platform isequaltostring:@"ipad2,2"])      return @"ipad 2 (gsm)";         if ([platform isequaltostring:@"ipad2,3"])      return @"ipad 2 (cdma)";         if ([platform isequaltostring:@"ipad2,5"])      return @"ipad mini (wifi)";         if ([platform isequaltostring:@"ipad2,6"])      return @"ipad mini (gsm)";         if ([platform isequaltostring:@"ipad2,7"])      return @"ipad mini (cdma)";         if ([platform isequaltostring:@"ipad3,1"])      return @"ipad 3 (wifi)";         if ([platform isequaltostring:@"ipad3,2"])      return @"ipad 3 (cdma)";         if ([platform isequaltostring:@"ipad3,3"])      return @"ipad 3 (gsm)";         if ([platform isequaltostring:@"ipad3,4"])      return @"ipad 4 (wifi)";         if ([platform isequaltostring:@"ipad3,5"])      return @"ipad 4 (gsm)";         if ([platform isequaltostring:@"ipad3,6"])      return @"ipad 4 (cdma)";          if ([platform isequaltostring:@"ipad4,1"])      return @"ipad air (wifi)";         if ([platform isequaltostring:@"ipad4,2"])      return @"ipad air (gsm)";         if ([platform isequaltostring:@"ipad4,3"])      return @"ipad air (cdma)";         if ([platform isequaltostring:@"ipad5,3"])      return @"ipad air 2 (wifi)";         if ([platform isequaltostring:@"ipad5,4"])      return @"ipad air 2 (cdma)";          if ([platform isequaltostring:@"ipad4,4"])      return @"ipad mini retina (wifi)";         if ([platform isequaltostring:@"ipad4,5"])      return @"ipad mini retina (cdma)";         if ([platform isequaltostring:@"ipad4,7"])      return @"ipad mini 3 (wifi)";         if ([platform isequaltostring:@"ipad4,8"])      return @"ipad mini 3 (cdma)";         if ([platform isequaltostring:@"ipad4,9"])      return @"ipad mini 3 (cdma)";           if ([platform isequaltostring:@"i386"])         return [uidevice currentdevice].model;         if ([platform isequaltostring:@"x86_64"])       return [uidevice currentdevice].model;          return platform;     }      @end 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -