0

I am new in Swift. I have 3 UIViewControllers:

  1. MainScreenController
  2. RegistrationFormController
  3. LoginFormController

and 1 UITabBarController

  1. MainTabBarController

and 2 ColletionViewControllers:

  1. VideoController
  2. TopVideoController

When I click on the button on the LoginFormController to open MainTabBarController with either 2 ColletionViewControllers seems an error, the error is mentioned below:

'UICollectionView must be initialized with a non-nil layout parameter'

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
}

Help me to understand how it works.

vadian
  • 232,468
  • 27
  • 273
  • 287

1 Answers1

0

From the Apple Documentation, you need to use init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) when initializing your collection view controllers.

Xcoder
  • 1,374
  • 3
  • 15
  • 29