我试图制作一个类似苹果跳板(所有应用程序所在的地方)的视图,这样我就可以向右或向左滑动,并显示另一组项目。我主要是有问题的约束和使所有的图标显示在所有屏幕的大小正常。我只使用一个基本的UIView控制器来尝试完成这个任务。对苹果的跳板等一系列图像使用约束的最佳方法是什么?
谢谢你的帮助。
发布于 2017-03-29 18:20:22
在故事板中,我拖动了一个UIPageViewController和两个UIViewController。我将UIPageViewController子类为MyPageViewController。
其余部分是通过MyPageViewController.swift中的代码完成的:
override func viewDidLoad() {
super.viewDidLoad()
// can't be done in storyboard (-_-)
delegate = self
datasource = self
setViewControllers([page1, page2], direction: .forward, animated: false, completion: nil)
}(其中page1和page2是故事板的另两个UIViewController )
如果您想知道如何获得page1 (在故事板中设置标识符之后):
let page1 = UIStoryboard(name: "MyStoryboard", bundle: nil).instantiateViewController(withIdentifier: "page1")https://stackoverflow.com/questions/43100706
复制相似问题