我创建了一个基于页面的应用程序,该应用程序已经具有多个视图。RootViewController负责设置应用程序布局,除了一件事(视图大小)外,其他所有功能都做得很好。
这是我所拥有的一部分
// Configure the page view controller and add it as a child view controller
self.pageViewController = UIPageViewController(
transitionStyle: .Scroll,
navigationOrientation: .Horizontal,
options: nil
);
self.pageViewController.delegate = self;
// Setup the initial page
let startingViewController = self.modelController.viewControllerWithProfileProvider(
self.profileProviderPreference(),
storyboard: self.storyboard
);
self.pageViewController.setViewControllers(
[startingViewController as BrowsingViewControllerBase] as [AnyObject],
direction: UIPageViewControllerNavigationDirection.Forward,
animated: false,
completion: { done in }
);
self.pageViewController.dataSource = self.modelController;
self.addChildViewController(self.pageViewController);
self.view.addSubview(pageViewController.view);
// Set the page view controller's bounds using an inset rect so that self's view is visible around the edges of the pages
self.pageViewController.view.frame = self.view.bounds;
// Notify the page view controller that we just moved to it. This is a framework imposition. See the docs.
self.pageViewController.didMoveToParentViewController(self);
// Add the page view controller's gesture recognizers to the view controller's view so that the gestures are started more easily.
self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
控制器中的所有其他代码都处理行为,而不处理方面,因此我使用Storyboard设置了其他所有内容。该viewControllerWithProfileProvider:
方法返回正确的视图,该视图会显示在屏幕上,但显示不正确。这是我在情节提要中的内容:
然后,我根据给定的提供者(例如,Facebook,Twitter,LinkedIn ...)更改按钮的颜色和标签。但是我得到这个:
请注意该按钮如何关闭屏幕。我认为这self.pageViewController.view.frame = self.view.bounds;
是关键所在,但是我不确定该使用什么。如何使我的视图正确显示?
控制单击该框并向上拖动,然后从弹出菜单中选择“顶部空间到顶部布局”。在左侧和右侧执行相同的操作,并分别选择前导空间和尾随空间。希望运行您的应用程序有帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句