autorotation problem
I've created a testing program to explain my problem. My RootViewController will autorotation when device rotates by return YES in shouldAutorotateToInterfaceOrientation.
The RootViewController's view is a UITableView. There are 3 rows. The first row show "Portrait", the second row show "Landscape" and the third show "Autorotation". When I click the row, I'll push another DetailViewController by passing a int (0,1,2) in its initWithOrientation (init, without using IB) method.
Then inside DetailViewController's shouldAutorotateToInterfaceOrientation, I'll return according to the orientation value (0,1,2). For example, when orientation = 1, I'll only return YES for UIInterfaceOrientationPortrait or UIInterfaceOrientationPortraiUpsideDown.
This works fine inside the DetailViewController. But I have a problem. For example, the device's interface orientation is portrait, then when I click the row 1 which should be a Landscape orientation. But it's in portrait orientation. And problem exist too when I leave the DetailViewController. For example, when I enter into DetailViewController by click row 1 (the landscape orientation) and when I rotate to portrait, the interface is still in landscape which is correct because I only allow in landscape orientation. Then after I pop the DetailViewController, the interface is still in landscape which is not what I expected because I'm in RootViewController which should allow autorotation for all orientations.
Are there any solution to my problem? Thanks.
|