Forcing orientation change

后端 未结 2 545
不思量自难忘°
不思量自难忘° 2021-01-07 03:22

I have a tab based application in which one tab is available in both portrait and landscape mode, all the others are only available in portrait.

I am checking agains

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-07 03:28

    I think if you just use the following code and it should work well.

    - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    // this ensures that the view that will be shown is presented in a supportred rotation
    UIViewController *c = [[UIViewController alloc]init];
    [viewController presentModalViewController:c animated:NO];
    [viewController dismissModalViewControllerAnimated:NO];
    [c release];
    if ([UIViewController respondsToSelector:@selector(attemptRotationToDeviceOrientation)]) {
        // this ensures that the view will be presented in the orientation of the device
        // This method is only supported on iOS 5.0.  iOS 4.3 users may get a little dizzy.
        [UIViewController attemptRotationToDeviceOrientation];
    }
    

    }

提交回复
热议问题