我正在尝试以编程方式创建新的视图控制器,而不是在Xcode上使用情节提要。我对编码非常陌生,不了解在框架所在的括号中必须输入的值。该代码全部位于应用程序委托中,请您帮忙。
let layout = UICollectionViewFlowLayout()
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: Homecontroller(frame: -, collectionViewLayout: layout))
答案 0 :(得分:0)
检查
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()
}
}