【问题标题】:iphone for Orientation [duplicate]iphone的方向[重复]
【发布时间】:2011-08-23 01:12:59
【问题描述】:

可能重复:
How to force a screen orientation in specific view controllers?

你好

我想在一个特定的视图中设置方向,那么我该怎么做。和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 ];
        }
    }
}

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

【问题讨论】:

标签: iphone uiinterfaceorientation


【解决方案1】:
// 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
}

【讨论】:

    【解决方案2】:

    在你的类中添加这个方法

    - (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;
    }
    

    【讨论】:

      【解决方案3】:

      在一个特定的视图控制器上放

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

      这是为其他你可以明智地做的肖像画

      【讨论】:

        猜你喜欢
        • 2011-04-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-19
        • 1970-01-01
        • 2014-11-08
        相关资源
        最近更新 更多