Ios containerView中嵌入的PageViewController显示以前视图的小范围
我创建了一个带有containerView的viewController,其中嵌入了一个pageViewController。在这个pageController中,我在其中添加了3个ViewController。这似乎很好,但是每次我滑动到下一个视图时,它似乎会在上一个视图的一侧显示一点边距。这是什么原因造成的 ViewDidLoadIos containerView中嵌入的PageViewController显示以前视图的小范围,ios,swift,uipageviewcontroller,Ios,Swift,Uipageviewcontroller,我创建了一个带有containerView的viewController,其中嵌入了一个pageViewController。在这个pageController中,我在其中添加了3个ViewController。这似乎很好,但是每次我滑动到下一个视图时,它似乎会在上一个视图的一侧显示一点边距。这是什么原因造成的 ViewDidLoad if let firstViewController = orderedViewControllers.first { self.pag
if let firstViewController = orderedViewControllers.first {
self.pageViewController?.setViewControllers([firstViewController],
direction: .Forward,
animated: true,
completion: nil)
}
newViewController
func newViewController(view: String) -> UIViewController {
return UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier(view)
}
PageControllerDelegate
extension CameraViewController: UIPageViewControllerDataSource {
func pageViewController(pageViewController: UIPageViewController,
viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = orderedViewControllers.indexOf(viewController) else {
return nil
}
let previousIndex = viewControllerIndex - 1
// User is on the first view controller and swiped left to loop to
// the last view controller.
guard previousIndex >= 0 else {
return orderedViewControllers.last
}
guard orderedViewControllers.count > previousIndex else {
return nil
}
return orderedViewControllers[previousIndex]
}
func pageViewController(pageViewController: UIPageViewController,
viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = orderedViewControllers.indexOf(viewController) else {
return nil
}
let nextIndex = viewControllerIndex + 1
let orderedViewControllersCount = orderedViewControllers.count
// User is on the last view controller and swiped right to loop to
// the first view controller.
guard orderedViewControllersCount != nextIndex else {
return orderedViewControllers.first
}
guard orderedViewControllersCount > nextIndex else {
return nil
}
return orderedViewControllers[nextIndex]
}
}
您可能会谈论页面间距。您可以在故事板中编辑它。选择页面视图控制器,然后打开属性检查器。将有相应的部分: