小编use*_*047的帖子

旋转呈现视图并锁定呈现视图控制器的方向

我正在开发仅支持横向的 iPad 应用程序,我希望允许某些呈现的视图控制器支持所有方向,而无需更改呈现视图控制器的方向。除了颠倒之外,我支持 Xcode 设置中的所有方向。

我用来呈现视图控制器的代码

    ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"];
    vc.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentViewController:vc animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

我用来允许呈现的视图控制器方向的代码:

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

You Tube应用程序在播放视频时提供相同类型的功能,知道它是如何工作的吗?

任何帮助将不胜感激,谢谢。

iphone objective-c orientation ipad ios

5
推荐指数
1
解决办法
848
查看次数

标签 统计

ios ×1

ipad ×1

iphone ×1

objective-c ×1

orientation ×1