0
votes

We have certain views in Portrait mode only, and certain views in Landscape mode only. We need to switch back and forth between these views using and option button appearing in side navigation. By pressing button side navigation will open up, Side Navigation should works for both Portrait and Landscape Mode.

By default the Landing screen is in Portrait mode, from there user can switch to Landscape view and vice versa.

For Views appearing in Landscape mode they have to properly appear in Landscape mode no matter user is holding device in Portrait orientation at that moment, When Landscape view is displayed user shell be rotating device to Landscape to play with it and vice versa for Landscape to Portrait shift.

What will be a appropriate solution

1

1 Answers

0
votes

You have to override this method in your view Controller's - - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

In view controllers where you want only portrait, use -

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {  

  return (interfaceOrientation == UIInterfaceOrientationPortrait ||    interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown );
} 

and in view controller, where you want landscape mode, use -

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {  

    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||     interfaceOrientation == UIInterfaceOrientationLandscapeRight);
 }