我正在尝试以编程方式创建一个新的 View Controller ,而不是使用 Xcode 上的 Storyboard。我对编码很陌生,不明白我必须在框架所在的括号中加上什么值。代码全部在应用程序委托(delegate)上,请您帮忙。
let layout = UICollectionViewFlowLayout()
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: Homecontroller(frame: -, collectionViewLayout: layout))
最佳答案
检查这个
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let layout = UICollectionViewFlowLayout()
window?.rootViewController = UINavigationController(rootViewController: HomeController(collectionViewLayout: layout))
你的 HomeController 应该是这样的
class HomeController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
关于ios - 创建新的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51101537/