2

All version and phones are okay, running smoothly but in iPhone 11 Everything just turned black. I am not using storyboard, the UI are made in code and the pattern is MVVMC. Any idea why on in iPhone 11 the app turned black?

Images: https://i.stack.imgur.com/hnjdG.png

This is the view hierarchy: https://www.dropbox.com/s/e3mzzpwn8iozhc0/Screen%20Shot%202019-10-08%20at%2012.11.18%20PM.png?dl=0

[EDIT: PLEASE TAKE NOTE THAT THE APP WAS BUILT IN XCODE 10.2.1]

The rootViewcontroller is TabBarController.

in AppDelegate.swift

var window: UIWindow?
private var appCoordinator: AppCoordinator!

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    FirebaseApp.configure()

    window = UIWindow()
    appCoordinator = AppCoordinator(window: window!)
    appCoordinator.start{}

    return true
}

func applicationWillTerminate(_ application: UIApplication) {
    //TODO: avoid relogout

}

in TabCoordinator.swift

enum SectionTab: Int, Menu {
    //case home
    case futures
    case trading
    case wallet
    case account

    func title(languageManager: LanguageManager) -> String {
        switch self {
        //case .home: return languageManager.localizedString("router.home")
        case .futures: return languageManager.localizedString("router.futures")
        case .trading: return languageManager.localizedString("router.spot")
        case .wallet: return languageManager.localizedString("router.wallets")
        case .account: return languageManager.localizedString("router.account")
        }
    }

    var image: UIImage {
        switch self {
        //case .home: return UIImage.init(named: "icTabHome")!
        case .futures: return UIImage.init(named: "icTabFutures")!
        case .trading: return UIImage.init(named: "icTabTrading")!
        case .wallet: return UIImage.init(named: "icTabWallet")!
        case .account: return UIImage.init(named: "icTabAccount")!
        }
    }

    var highlightedImage: UIImage {
        switch self {
        //case .home: return UIImage.init(named: "icTabHomeActive")!
        case .futures: return UIImage.init(named: "icTabFutures")!
        case .trading: return UIImage.init(named: "icTabTradingActive")!
        case .wallet: return UIImage.init(named: "icTabWalletActive")!
        case .account: return UIImage.init(named: "icTabAccountActive")!
        }
    }

}

init(window: UIWindow, dependencies: Dependencies) {
    self.window = window
    self.dependencies = dependencies
}

override func start(completion: @escaping CoordinatorCompletion) {
    super.start(completion: completion)

    let tabbarController = UITabBarController()
    let tabs : [SectionTab] = [.futures, .trading, .wallet, .account]
    let viewControllers = createViewControllers(tabs: tabs)

    tabbarController.viewControllers = viewControllers.map{ $0.viewController }
    tabbarController.view.backgroundColor = .white
    tabbarController.tabBar.tintColor = UIColor.appLightBlue
    tabbarController.tabBar.unselectedItemTintColor = UIColor.appDarkGray

    let notification = Notification.Name.init(LanguageChangedNotification)
    NotificationCenter.default.rx.notification(notification).subscribe({_ in
        tabbarController.viewControllers?.enumerated().forEach({ (arg0) in
            let (offset, vc) = arg0
            vc.tabBarItem.title = tabs[offset].title(languageManager: self.dependencies.languageManager)
        })
    }).disposed(by: disposeBag)

    window.rootViewController = tabbarController
    window.makeKeyAndVisible()
}

private func createViewControllers(tabs: [SectionTab]) -> [(viewController: UIViewController, coordinator: BaseCoordinator)] {
    return tabs.map({ (tab) -> (viewController: UIViewController, coordinator: BaseCoordinator) in
        let viewController: UIViewController

        let coordinator: BaseCoordinator
        switch tab {
        case .futures:
            viewController = BTSENavigationController()
            coordinator = FuturesCoordinator(navigationController: viewController as! BTSENavigationController, dependencies: dependencies)
            coordinate(to: coordinator)
        case .trading:
            viewController = BTSENavigationController()
            coordinator = SpotCoordinator(navigationController: viewController as! BTSENavigationController, dependencies: dependencies)
            coordinate(to: coordinator)
        case .wallet:
            viewController = BTSENavigationController()
            coordinator = WalletCoordinator(navigationController: viewController as! BTSENavigationController, dependencies: dependencies, url: self.dependencies.client.url(for: .wallets))
            coordinate(to: coordinator)
        case .account:
            viewController = BTSENavigationController()
            coordinator = AccountCoordinator(navigationController: viewController as! BTSENavigationController, dependencies: dependencies)
            coordinate(to: coordinator)
        }

        viewController.tabBarItem = UITabBarItem.init(title: tab.title(languageManager: dependencies.languageManager), image: tab.image, selectedImage: tab.highlightedImage)

        return (viewController: viewController, coordinator: coordinator)
    })
}
lunes
  • 37
  • 5
  • 2
    In iOS 13 you don't use the AppDelegate to create the window, you use the SceneDelegate unless you've taken steps to opt out of using scenes. – rmaddy Sep 27 '19 at 04:10
  • It works on other devices but not in iPhone 11 – lunes Sep 27 '19 at 04:22
  • Are the other devices running iOS 13? – rmaddy Sep 27 '19 at 04:23
  • Yes. iOS 13 iPhone 8 and X – lunes Sep 27 '19 at 04:37
  • I just made a simple test app. I [fully opted out of supporting scenes](https://stackoverflow.com/a/57467270/1226963) in this test app. Running it on an iPhone 8 or an iPhone 11 simulator (iOS 13) worked just fine. – rmaddy Sep 27 '19 at 05:05
  • Taking a closer look at the screenshot you posted, the status bar isn't black. This indicates that the problem isn't an issue with opting out of scenes. If that was the problem, the status bar would be black too. You have some other problem with how your user interface is setup. – rmaddy Sep 27 '19 at 05:08
  • Have you tried disabling dark mode? You can do so by adding the following key/value to the `Info.plist` file: `UIUserInterfaceStyle Light` – marcelosalloum Sep 27 '19 at 17:01
  • Yes I tried but nothing happens. – lunes Sep 29 '19 at 16:30
  • I am still stuck why it only happens on iPhone 11 – lunes Oct 03 '19 at 07:34
  • Hi Guys, Help on this one. This is the UI inspector of the app. The UIView is not on full HEIGHT and idk why. Please see image, https://www.dropbox.com/s/e3mzzpwn8iozhc0/Screen%20Shot%202019-10-08%20at%2012.11.18%20PM.png?dl=0 – lunes Oct 08 '19 at 04:14

1 Answers1

0

even if i just do this on the AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        FirebaseApp.configure()

        window = UIWindow()
        window.rootViewController = UIViewController() //this should show white screen

        return true
}

The app will show black screen since the rootviewController has no delegate. Seems like I really have to implement the Scenedelegate.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
lunes
  • 37
  • 5