Reputation: 29
I am a new developer in iOS Developing. I faced a problem on current device. According to requirement i have to design app for all device. So anybody can help me how to get Current device & current platform of iOS?
For current device i am using this code:
NSString *deviceType = [[UIDevice currentDevice] model];
My requirement is i have to adjust UITableView
row height according to device.
I think you got my question. If you need any information please tell me.
Thanks in advanced.
Upvotes: 0
Views: 719
Reputation: 4843
Ok try this one.
NSString *deviceType = [[UIDevice currentDevice] model]; // for current device
if ([deviceType isEqualToString:@"iPhone"])
{
NSString *platform = [self platformRawString];
NSLog(@"platform :%@",platform);
// To set the half cut in the last cell.
if ([platform isEqualToString:@"iPhone2,1"])
//cellHeight = 39.5;
else if ([platform isEqualToString:@"iPhone4,1"])
//cellHeight = 42;
else if ([platform isEqualToString:@"iPhone5,3"] || [platform isEqualToString:@"iPhone5,4"])
//cellHeight = 42.5;
else
//cellHeight = 40.0;
}
Method for getting platform
- (NSString *)platformRawString
{
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;
}
Upvotes: 1