0

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 Answers 4

2

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

Refer to userInterfaceIdiom property of UIDevice

0

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

-1

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;
}
2
  • There's available hi-level classes and functions that allows to determine device type application is running on. No need to rely on low-level API, this may cause incompatibility and other troubles in future.
    – Andriy
    Jul 19, 2011 at 11:01
  • You're right about there is no need to rely on low-level api to determine the device type, but i could not find resources to determine the hardware model name.
    – Mat
    Jul 19, 2011 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.