iOS6 Interface Orientation
In iOS6 for interface orientation shouldAutorotateToInterfaceOrientation: method is deprecated.
If you want to make only one controller to orient in all directions but want to restrict a single controller to a specific direction like Portrait then follow:
1. Subclass a UINavigationController and inherit it
2. Override few orientation methods in ViewController in which you want or restrict the orientation support.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-(NSUInteger)supportedInterfaceOrientations
If you want to restrict a ViewController to rotate only in Portrait mode then add code:
#pragma Orientation (override methods)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
{
return NO;
}{
return UIInterfaceOrientationMaskPortrait;
}If you want to allow all orientations on a ViewController then add below code:
#pragma Orientation (override methods)
-(BOOL)shouldAutorotate{
return YES;
}{
return UIInterfaceOrientationMaskAll;
}You can download sample code : Code Here
I followed below link for help:
Comments
Post a Comment