0
votes

My app is an iphone app not an universal app.I am implementing uiimagepickercontroller it's working fine in iphone .But our client test my app on ipad the app will crash.I find out the issue 'On iPad, UIImagePickerController must be presented via UIPopoverController'
I am checking device by

NSString *deviceType = [UIDevice currentDevice].model;

(This code work in universal app) implementing UIPopoverController for iPad only. But deviceType always displays 'iPhone' even if i change to iPad simulator.Is it possible to solve this issue in iphone Build?

4

4 Answers

2
votes

You should use UI_USER_INTERFACE_IDIOM macro to check for device.

if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM())
{
    // your code
}

UIDevice is not the right choice here.

0
votes

Refer to userInterfaceIdiom property of UIDevice

0
votes

I did iPad for separately to solve this issue.because i can't get a device type iPad in iPhone app.

-1
votes

Like Erica Sadun said you can access device string with:

- (NSString *) getSysInfoByName:(char *)typeSpecifier
{
    size_t size;
    sysctlbyname(typeSpecifier, NULL, &size, NULL, 0);
    char *answer = malloc(size);
    sysctlbyname(typeSpecifier, answer, &size, NULL, 0);
    NSString *results = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
    free(answer);
    return results;
}