ios7ios8iphone-4

How to detect if the UIMotionEffect is supported?


Is there a way to detect if the UIMotionEffect is supported on the device my app is running on?


Solution

  • You can test it like this :

    if ([UIMotionEffect class]) {
        // do stuff with UIMotionEffect
    } else {
        // UIMotionEffect does not exists
    }
    

    In iOS < 4.2 do it like this :

    Class theClass = NSClassFromString(@"UIMotionEffect");
    if (theClass) {
        // do stuff with UIMotionEffect
    } else {
        // UIMotionEffect does not exists
    }