我遇到了一个奇怪的问题,而我UIViewControllers
中的UIPageViewController
宽度为 328 ,而不是 320 并且似乎正在流出他们的界限。
当查看说出页面索引0时,我可以在右侧看到一个或两个页面索引1。 为什么会这样?我正在使用AutoLayout并像这样创建我的UIPageViewController
:
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:@{UIPageViewControllerOptionInterPageSpacingKey : [NSNumber numberWithFloat:pageSpacing]}];
self.pageViewController.dataSource = self;
self.pageViewController.delegate = self;
[self.pageViewController willMoveToParentViewController:self];
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
/* remove dots */
NSArray *subviews = self.pageViewController.view.subviews;
UIPageControl *bottomControl = nil;
for (int i=0; i<[subviews count]; i++) {
if ([[subviews objectAtIndex:i] isKindOfClass:[UIPageControl class]]) {
bottomControl = (UIPageControl *)[subviews objectAtIndex:i];
}
}
bottomControl.hidden = true;
/* set viewcontrollers */
self.navViewControllers = @[
leftViewController,
centerViewController,
rightViewController
];
[self.pageViewController setViewControllers:@[self.navViewControllers[1]] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];