代码之家  ›  专栏  ›  技术社区  ›  jmont

系统忽略iPhone旋转

  •  1
  • jmont  · 技术社区  · 15 年前

    UIApplication中是否有类似beginIgnoringInteractionEvents的函数忽略旋转而不是触摸?我需要我的应用程序不只是在一个旋转 MPMovePlayerViewController 我现在介绍的。

    谢谢

    [更新]

    这是我的密码--

    MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]];
    [mpViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
    [self presentMoviePlayerViewControllerAnimated:mpViewController];
    [mpViewController release];
    

    我通过添加shouldAutoRotatePointerFaceOrientation:和setStatusBaroOrientation:方法来实现它。它在模拟器中工作。但是,如果我在播放视频时旋转iPhone,状态栏也会旋转,并保持“固定”在纵向方向。

    我的问题在 http://i28.tinypic.com/357mrub.png

    [更新2]

    通过子类化mpmovieplayervewcontroller(并实现shouldAutorotate方法),程序将按其应该的方式旋转。只有视频没有播放,因为

    [self presentMoviePlayerViewControllerAnimated:mpViewController];
    

    不接受我的子类。

    “警告:不兼容的Objective-C类型”“struct NoRotate*”“,在从不同的Objective-C类型传递”“presentMoviePlayerViewController*”“的参数1时应为”“struct MPMoviePlayerViewController*”“。”

    2 回复  |  直到 15 年前
        1
  •  6
  •   MystikSpiral    15 年前

    在您当前的视图中,实现shouldAutoRotate方法并简单地返回“NO”。这将导致手机忽略任何和所有方向的变化。

        2
  •  0
  •   Pieter Jongsma    15 年前

    // NotRotatingMoviePlayerViewController.h
    @interface NotRotatingMoviePlayerViewController : MPMoviePlayerViewController {
    }
    
    @end
    
    // NotRotatingMoviePlayerViewController.m
    @implementation
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
      return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    
    @end