向きを変えずに背骨の位置を変えることはできますか?一部のビューと同様に、最大に設定され、一部のビューでは中央に設定されている必要があります。この機能をアクティブにすることは可能ですか?
これは私が使用しているコードですが、向きを変更せずに背表紙の位置を最大に設定し、2ページモードではなく1ページモードを設定できるように、何を変更すればよいかわかりません。実際には、アプリの実行時に2ページモードで開始されますが、後でシングルページモードに移行する必要があります。これは不可能であり、1つのビューを提供しているが、2つよりも必要であるというエラーが発生します。誰でもこれをガイドできますか?
-(id)initWithViewControllers:(NSMutableArray *)Controllers
{
self = [super initWithNibName:nil bundle:nil];
if(self)
{
self.VControllers = Controllers;
pageController = [[UIPageViewController alloc]initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation: UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageController.view.frame = CGRectMake(12.0f, 10.0f, 748.0f, 985.0f);
self.pageController.delegate = self;
self.pageController.dataSource = self;
[self.pageController setViewControllers:[NSArray arrayWithObject:[VControllers objectAtIndex:0] ] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished)
{
}];
[self addChildViewController:self.pageController];
[self.view addSubview:self.pageController.view];
check=YES;
}
return self;
}
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if(UIInterfaceOrientationIsPortrait(orientation))
{
//Set the array with only 1 view controller
UIViewController *currentViewController = [self.pageController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
//Important- Set the doubleSided property to NO.
self.pageController.doubleSided = NO;
//Return the spine location
return UIPageViewControllerSpineLocationMax;
}
else
{
NSArray *viewControllers = nil;
exampleViewController *currentViewController = [self.pageController.viewControllers objectAtIndex:0];
NSUInteger currentIndex = [self.VControllers indexOfObject:currentViewController];
if(currentIndex == 0 || currentIndex %2 == 0)
{
UIViewController *nextViewController = [self pageViewController:self.pageController viewControllerAfterViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:currentViewController, nextViewController, nil];
}
else
{
UIViewController *previousViewController = [self pageViewController:self.pageController viewControllerBeforeViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:previousViewController, currentViewController, nil];
}
//Now, set the viewControllers property of UIPageViewController
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
return UIPageViewControllerSpineLocationMid;
}
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
int index = [self.VControllers indexOfObject:viewController];
i=index;
//[self checkViewControllers];
if (index - 1 >= 0)
{
ind = index;
return [self.VControllers objectAtIndex:index - 1];
}
return nil;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
int index = [self.VControllers indexOfObject:viewController];
i=index;
if (index + 1 < [self.VControllers count])
{
ind = index;
return [self.VControllers objectAtIndex:index + 1];
}
if (ind1 + 1 < [self.VControllers count])
{
ind = index;
return [self.VControllers objectAtIndex:index + 1];
}
return nil;
}