Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS:pageViewController界面方向_Ios_Iphone_Uiviewcontroller_Uipageviewcontroller_Uiinterfaceorientation - Fatal编程技术网

IOS:pageViewController界面方向

IOS:pageViewController界面方向,ios,iphone,uiviewcontroller,uipageviewcontroller,uiinterfaceorientation,Ios,Iphone,Uiviewcontroller,Uipageviewcontroller,Uiinterfaceorientation,我用代码创建它: self.pageViewController = [[PageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:@{ UIPageViewControllerOptionInterPageS

我用代码创建它:

self.pageViewController = [[PageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:@{ UIPageViewControllerOptionInterPageSpacingKey : @30 }];
self.pageViewController.delegate = self;
self.pageViewController.dataSource = self;
self.pageViewController.automaticallyAdjustsScrollViewInsets = NO;
self.currentMediaPlayerViewController = [self createMediaPlayerViewControllerWithMediaItem:self.mediaItems[self.pageIndex]];
NSArray *pageViewControllers = @[self.currentMediaPlayerViewController];
[self.pageViewController setViewControllers:pageViewControllers
                                  direction:UIPageViewControllerNavigationDirectionForward
                                   animated:NO
                                 completion:nil];
[self addChildViewController:self.pageViewController];
[self.pageViewController didMoveToParentViewController:self];
[self.view addSubview:self.pageViewController.view];
我仅在parentVC中启用横向指向pageViewController。但仍然可以抓住旋转

- (void)viewDidLoad
{

self.navigationController.delegate = self;

NSNumber *value = @(UIInterfaceOrientationLandscapeLeft);
NSString *keyOrientation = @"orientation";
if (![value isEqualToNumber:@((NSInteger)[[UIDevice currentDevice] valueForKey:keyOrientation])]) {
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}


- (NSUInteger)navigationControllerSupportedInterfaceOrientations: (UINavigationController *)navigationController
{
return UIInterfaceOrientationMaskLandscape;
如何在pageViewController中仅启用横向定向?

请尝试使用此代码

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    if (self.isLandscapeOK) {
        // for iPhone, you could also return UIInterfaceOrientationMaskAllButUpsideDown
        return UIInterfaceOrientationMaskAll;
    }
    return UIInterfaceOrientationMaskPortrait;
}