要做视频播放的视图,要求横屏播放可是我的整个应用是只支持竖屏 ios5下在视频视图横屏用
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}可是ios6下横屏怎么写?谢谢

解决方案 »

  1.   

    如果是全部竖屏,就在plist里面设置,如果每个页面不一样,就在不同页面设置,ios6废弃了这个方法!
      

  2.   

    iOS6的话,文档里说明:shouldAutorotateToInterfaceOrientation:
    Returns a Boolean value indicating whether the view controller supports the specified orientation. (Deprecated in iOS 6.0. Override the supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation methods instead.)
    重载supportedInterfaceOrientations 和 preferredInterfaceOrientationForPresentation 两个函数协作完成。
      

  3.   

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation != UIInterfaceOrientationMaskLandscapeLeft);
    }-(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscapeRight;
    }-(BOOL)shouldAutorotate
    {
        return YES;
    }5,6通吃。
      

  4.   

    最近很多人在问这个问题??在相对应的视图控制器(ViewController.m)的viewDidLoad方法中加入下面代码
    CGAffineTransform transform = CGAffineTransformIdentity;
        transform = CGAffineTransformRotate(transform, M_PI/2);
        self.view.transform = transform;
    注意此时视图横屏了但是状态栏还是纵屏显示的,所以需要修改状态栏方向(alertview的方向也会随之修改)
    [[UIApplication sharedApplication]setStatusBar。。
      

  5.   

    在view里重栽以下方法- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }-(BOOL)shouldAutorotate
    {
        return NO;
    }-(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
      

  6.   


    up
    但-(BOOL)shouldAutorotate 这个方法 YES也可
      

  7.   

    首先,你得说明你的整个视图控制器的结构是怎么样的,在IOS6下,这个层次很重要,不然就算你的某个视图中加了那几个控制旋转的方法也起不了作用;你如果用了navigationcontroller,那么请在根navigationcontroller中填写控制旋转的方法就可以了,如果你其他视图要另外控制不同的旋转方向,就可以给再加一个navigationcontroller,旋转代码同理写在这个navigationcontroller中;这也就以为着你需要继承写navigationcontroller用来填写旋转方向的代码;
      

  8.   

    还有一个比较关键的地方,在appdelegate中用window.rootViewController=yourrootviewcontroller替换原来ios5中的
    [window addsubview:yourrootviewcontroller.view]
      

  9.   

    能教教代码怎么写么?我也用了navigationcontroller,但是代码不知道怎么写呢,求大神救救小女子吧
      

  10.   

    iOS6的方法楼上面都有说明了,你要注意VC的结构。如果没有起到你要的效果,就是当前VC在当前Windows上还有父VC
      

  11.   

    14楼正确,一定要在父类的viewController上面设置,比如所有的ViewController都是在TabbarViewController之上,那么就应该在TabbarViewController里面设置
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    即可同理,如果是在某一个NavigationController里面,那么就设置这个NavigationController即可
      

  12.   

    一定要在父类的viewController上面设置