Reputation: 1232
I have this code and it works perfectly on iOS 5 but not on iOS 6 please help
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
return (orientation != UIDeviceOrientationPortrait) &&
(orientation != UIDeviceOrientationPortraitUpsideDown);
}
Upvotes: 1
Views: 192
Reputation: 490
let try this :
First inside viewDidLoad
function use this code :
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}
then, i'm create function that will receive notification for two lines of code :
- (void)orientationChanged:(NSNotification *)object{
NSLog(@"orientation change");
UIDeviceOrientation deviceOrientation = [[object object] orientation];
if(deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown){
if(deviceOrientation ==UIInterfaceOrientationPortrait){
NSLog(@"Changed Orientation To Portrait");
// Handle your view.
}
}else{
if(deviceOrientation ==UIInterfaceOrientationLandscapeLeft){
NSLog(@"Changed Orientation To Landscape left");
// Handle your view.
}else{
NSLog(@"Changed Orientation To Landscape right");
// Handle your view.
}
}
}
i hope my answer will help. Cheers.
Upvotes: 2
Reputation: 3738
In iOS6, "shouldAutorotateToInterfaceOrientation" method is deprecated.Try setting orientation in plist file.
Upvotes: 1