How Do I detect the orientation of the device on iOS?

Really old thread, but no real solution. I Had the same problem, but found out that getting The UIDeviceOrientation isn’t always consistent, so instead use this: UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if(orientation == 0) //Default orientation //UI is in Default (Portrait) — this is really a just a failsafe. else if(orientation == UIInterfaceOrientationPortrait) //Do something … Read more

API to determine whether running on iPhone or iPad [duplicate]

Checkout UI_USER_INTERFACE_IDIOM. Returns the interface idiom supported by the current device. Return Value UIUserInterfaceIdiomPhone if the device is an iPhone or iPod touch or UIUserInterfaceIdiomPad if the device is an iPad. UIUserInterfaceIdiom The type of interface that should be used on the current device typedef enum { UIUserInterfaceIdiomPhone, UIUserInterfaceIdiomPad, } UIUserInterfaceIdiom;

iOS: Device orientation on load

EDIT: I mis-read your question. This will allow you to start your application in certain orientations. Just realized you’re trying to figure out the orientation on launch. There is a method to check the status bar orientation on UIApplication: [[UIApplication sharedApplication] statusBarOrientation]; Original answer Try setting the application’s accepted device orientations in the plist file: … Read more

Detecting iOS UIDevice orientation

Try doing the following when the application loads or when your view loads: [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]]; Then add the following method: – (void) orientationChanged:(NSNotification *)note { UIDevice * device = note.object; switch(device.orientation) { case UIDeviceOrientationPortrait: /* start special animation */ break; case UIDeviceOrientationPortraitUpsideDown: /* start special animation */ … Read more

Detecting Color of iPhone/iPad/iPod touch?

There’s a private API to retrieve both the DeviceColor and the DeviceEnclosureColor. UIDevice *device = [UIDevice currentDevice]; SEL selector = NSSelectorFromString(@”deviceInfoForKey:”); if (![device respondsToSelector:selector]) { selector = NSSelectorFromString(@”_deviceInfoForKey:”); } if ([device respondsToSelector:selector]) { NSLog(@”DeviceColor: %@ DeviceEnclosureColor: %@”, [device performSelector:selector withObject:@”DeviceColor”], [device performSelector:selector withObject:@”DeviceEnclosureColor”]); } I’ve blogged about this and provide a sample app: http://www.futuretap.com/blog/device-colors/ Warning: … Read more