简体   繁体   English

如何在特定视图中修复PageViewController

[英]How to fix PageViewController in specific view

I want to fix PageViewController views in specific view. 我想在特定视图中修复PageViewController视图。 When i load into ViewController main view it's working fine, but when i load it in subView PageViewController not fixing in that subView. 当我加载到ViewController主视图中时,它工作正常,但是当我将其加载到subView中时,PageViewController无法在该subView中修复。 How to fix PageViewController in subview. 如何在子视图中修复PageViewController。

Image 1, red colour view is ,my subView I want to fix PageViewController in this red colour view. 图像1,红色视图是我的子视图,我想在此红色视图中修复PageViewController。

在此处输入图片说明

image 2 , this is I'm getting. 图片2,这是我要的。

在此处输入图片说明

Based on your code in your other question, you are adding your page view to your (red) subview but not setting its frame. 根据另一个问题中的代码,您正在将页面视图添加到(红色)子视图中,但未设置其框架。

    // Create the page container
    pageContainer = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
    pageContainer.delegate = self
    pageContainer.dataSource = self
    pageContainer.setViewControllers([page1], direction: UIPageViewController.NavigationDirection.forward, animated: false, completion: nil)

    // Add it to the view
    pageControllerView.addSubview(pageContainer.view)

    // set the frame of the pageContainer view to match its superview (the red view)
    pageContainer.view.frame = pageControllerView.bounds
    // let it resize if needed (such as device rotation)
    pageContainer.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]

This should solve the issue. 应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 PageViewController 中打开一个特定的 View Controller - Open a specific View Controller in PageViewController 如何在pageViewController中移动到特定页面? - How to move to a specific page in a pageViewController? 如何跳到pageViewController中的特定页面 - How to jump at a specific page in pageViewController Obj-C:如何修复PageViewController,PageController和2个按钮的约束 - Obj-C: How to fix constraint for PageViewController, PageController and 2 buttons 从视图控制器到PageViewController - From view controller to PageViewController 如何为PageViewController演练使用不同的Xibs View Controller - How to Use Different Xibs View Controller for PageViewController Walkthrough (快速)如何通过触摸按钮在pageviewcontroller中更改视图 - (Swift) how can I change view in pageviewcontroller with touching button 如何从使用pageViewController返回到开始视图 - how to come back from using pageViewController to the start view 如何修复 UIPageControl 的位置? 当页面使用 PageViewController 更改时,它总是在顶部修复吗? - How fix position of UIPageControl ? Fix it always on top when page is changing with PageViewController? PageViewController并禁用拖动某些视图 - PageViewController and disable dragging certain view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM