我是Swift的新手。我有3 UIViewControllers
:
MainScreenController
RegistrationFormController
LoginFormController
和1 UITabBarController
MainTabBarController
和2 ColletionViewControllers
:
VideoController
TopVideoController
当我点击LoginFormController
上的按钮打开MainTabBarController
并显示2 ColletionViewControllers
似乎是错误时,错误如下所示:
必须使用非零布局参数初始化' UICollectionView'
的AppDelegate:
class CustomNavigationController: UINavigationController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var navigationController: UINavigationController?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
if let window = window {
let mainVC = MainScreenController()
navigationController = CustomNavigationController(rootViewController: mainVC)
window.rootViewController = navigationController
window.makeKeyAndVisible()
}
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().barTintColor = UIColor.darkBlue
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
FirebaseApp.configure()
return true
}
帮助我了解它的工作原理。
答案 0 :(得分:0)
从Apple Documentation开始,您需要在初始化集合视图控制器时使用init(frame: CGRect,
collectionViewLayout layout: UICollectionViewLayout)
。