开发者

Iphone Orientation Issues

I have an application with the a sructure as follows

  • UITabBarController (3 tabs)
    • UINavigationController (in each of the tabs)
      • UIViewController (in each of the Navigation controllers)

In it I want some of the UIviewControllers to be able to switch to both landscape and potrait modes

for example In Tab 2 I have a Picture G开发者_Python百科allery section (View 1) In it I have 9 Buttons for 9 Picture galleries When button 1 is touched the Navigation controller navigates to View 2 where users are able to browse through different photos. When the User touches a photo It Navigation controller navigates to View 3 for a full screen mode.

Now I want View 3 to be orientable to both Landscape and portrait mode. where as all previous views should only be viewed in portrait mode. How do i go about doing this?

I have already fiddled around with the

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

method in all the views but I just cant seem to get it right.


I had hard time with this situation.

2 ways to solve this :

1st
Use [[UIDevice currentDevice] setOrientation:whatever]; It will trigger a warning.

2nd
Use presentModalViewController:animated: And implement shouldAutorotateToInterfaceOrientation: in this Modal View Controller. If you want to keep the original transition animation you will have to code a bit though.


The root view controller (UITabBarController) in this case has to implement shouldAutorotateToOrientation: and then so does each child controller. so set the tab bar controller's method to YES, then for the ones you don't want anything but portrait just set it to return yes only for that view and etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜