I am working with a game that basically operates on landscape mode. It has an option of changing Profile Pic. The profile pic option opens the Image Picker which is used to display on the profile pic Image View. My issue is
When image picker is opened , the app automatically changes orientation to portrait.
For solving this, I tried to capture the orientation of the user when he clicks the upload image button and after selecting the image , I am forcefully changing the device orientation to previous one. Everything is working fine on iPhone 5 and higher versions. But iphone 4(running on ios7) crashes when the user selects an image from picker view. I am getting the following error -
preferredInterfaceOrientationForPresentation must return a supported interface orientation!
I am using this code to check the orientation of user
-(void)checkCurrentDeviceOrientation
{
if([UIDevice currentDevice].orientation ==
UIDeviceOrientationLandscapeRight || [UIDevice
currentDevice].orientation == UIDeviceOrientationLandscapeLeft )
{
self.currentOrientation = [UIDevice currentDevice].orientation;
}
else
{
self.currentOrientation = UIDeviceOrientationLandscapeRight;
}
}
and using this code to set the orientation.
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8"))
{
if([UIDevice currentDevice].orientation ==
UIDeviceOrientationPortrait ||[UIDevice currentDevice].orientation ==
UIDeviceOrientationPortraitUpsideDown )
{
NSLog(@"Chnaging Device Orientation to stored orientation");
NSNumber *value = [NSNumber numberWithInt:self.currentOrientation];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
}
else
{
//Code For IPHONE 4
}
Hopefully everything works fine on ios8 and higher but not on iphone 4 running on ios 7.0.1
Thanks In Advance!