views:

740

answers:

2

i have two viewcontroller one support orientation another not,but when i rotate in second viewcontroller (support orientation)to landscape,and back to first viewcontroller(not support orientation) at the mean time second view still remain landscape it will change the first view become landscape as well but it not suppose to be landscape while first viewcontroller is not support orientation,how to prevent this happen,

the thing i want is the first view will always be potrait no matter how u rotate the phone especially when back from second view and it was in landscape

pls help and thanks first

A: 

in viewWillAppear:Animated of your first controller, call

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

And of course, set up the shouldAutoRotateToInterfaceOrientation to return YES only on UIInterfaceOrientationPortrait.

Ed Marty
this only rotate the device back to potrail but my view was still in landscape,others way?
issac
You need to make sure the correct view controller is receiving the rotate events. Some times adding a view controller will cause that to receive events even after removing it; Also, I know with at least TabBarViewControllers, it doesn't send rotate events to its children, so you have to override.
Ed Marty
A: 

in viewWillAppear:Animated of your first controller, call [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];