gpt4 book ai didi

objective-c - UIPageViewController 和景观

转载 作者:太空狗 更新时间:2023-10-30 04:00:26 26 4
gpt4 key购买 nike

我一直在尝试以下方法,但没有任何效果

NSDictionary *pageViewOptions = [NSDictionary dictionaryWithObjectsAndKeys:UIPageViewControllerOptionSpineLocationKey, [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid],nil];
NSLog(@"pageViewOptions :%@",pageViewOptions);

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:pageViewOptions];
NSLog(@"spineLocation :%d",self.pageViewController.spineLocation);

pageViewOptions 的 NSlog 是 2,spineLocation 的 NSlog 是 1。这让我很困惑,我只想用中间的 spine 初始化。它总是在左边初始化。该应用程序以横向方式初始化,但仅在将设备旋转 180 度后才使用该方法“- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation”工作,然后我在中间得到脊柱。有人可以对此有所了解吗?我到处寻找答案。

我想要它做的就是在风景中初始化,中间有一个脊椎

最佳答案

尝试使用“options”参数:

NSDictionary *options = (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) ? [NSDictionary dictionaryWithObject: [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid] forKey: UIPageViewControllerOptionSpineLocationKey] : nil; 

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];

...

并且不要忘记初始化 2 个内容 View Controller :

NSArray *viewControllers = [NSArray arrayWithObjects:contentViewController1, contentViewController2, nil];

[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

关于objective-c - UIPageViewController 和景观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9246572/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com