I am trying to implement something where I stuck at one point.
I want some orientation restrictions as follows:
For iPhone 4, 4S, 5, 5S, & 6 - Portrait Only
For iPhone 6 Plus - Both Portrait & Landscape
For iPad - Both Portrait & Landscape
I have tried all the combination of coding. Finally I got solution for iOS 8
**(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window // iOS 6 autorotation fix
{**
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
{
if(IS_IPHONE_4_AND_OLDER){
printf("Device Type : iPhone 4,4s ");
return UIInterfaceOrientationMaskPortrait;
}
else if(IS_IPHONE_5){
printf("Device Type : iPhone 5,5S/iPod 5 ");
return UIInterfaceOrientationMaskPortrait;
}
else if(IS_IPHONE_6){
printf("Device Type : iPhone 6 ");
return UIInterfaceOrientationMaskPortrait;
}
else if(IS_IPHONE_6P){
printf("Device Type : iPhone 6+ ");
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait;
}
}
return UIInterfaceOrientationMaskPortrait;
}
else{
printf("Device Type : iPad");
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait;
}
}
By using above code I manage for iOS 8 But it does not work in iOS 7 or less
Please help me to solve this ...
Thank you
Simple but it work very fine. IOS 7.1 and 8
AppDelegate.h
AppDelegate.m
}
ViewController
At top: To Detect Device Type
Then Add Function Below:
viewDidLoad