[英]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.