0

可能重复:
如何在特定视图控制器中强制屏幕方向?

你好

我想在一个特定的视图中设置方向,所以我该怎么做。和body有例子。我用过

-(void)onUIDeviceOrientationDidChangeNotification:(NSNotification*)notification{
    UIViewController *tvc = self.navigationController.topViewController;
    UIDeviceOrientation orientation = [[ UIDevice currentDevice ] orientation ];
    tabBarController.view.hidden = YES;
    // only switch if we need to (seem to get multiple notifications on device)
    if( orientation != [[ UIApplication sharedApplication ] statusBarOrientation ] ){
        if( [ tvc shouldAutorotateToInterfaceOrientation: orientation ] ){
            [ self rotateInterfaceToOrientation: orientation ];
        }
    }
}

但它完成的是整个应用程序,我只想在一个屏幕上完成,所以请回复谢谢

4

3 回答 3

0
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // Over ride this method in your required view controller to display only in the necessary orientation
}
于 2011-05-11T06:49:28.773 回答
0

在您的课程中添加此方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // Over ride this method in your required view controller to display only in the necessary orientation
     return YES;
}
于 2011-05-11T06:50:44.857 回答
0

在一个特殊的视图控制器上

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

这是给其他人的肖像,你可以做同样的事情

于 2011-05-11T06:55:51.367 回答