因此,我有一个内置于xcode 10.2.1中的应用程序,然后我在Xcode 11上运行了该应用程序。该应用程序显示黑屏,因为视图的高度不足(仅48.0,为什么?)。所有设备都可以正常工作,但是在iOS 13上运行的iPhone 10和11确实存在错误。
注意:未使用情节提要,该应用程序是在Xcode 10.2.1,Swift 5,iOS 13 iPhone 5-8中正常运行的
这是视图的层次结构:https://www.dropbox.com/s/e3mzzpwn8iozhc0/Screen%20Shot%202019-10-08%20at%2012.11.18%20PM.png?dl=0
我尝试使用SceneDelegate,但没有成功。我还试图选择不使用场景。
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
}
AppCoordinator.swift
class AppCoordinator: BaseCoordinator {
private let window: UIWindow
private let dependencies: AppDependency
init(window: UIWindow) {
self.window = window
self.dependencies = AppDependency()
}
override func start(completion: @escaping CoordinatorCompletion) {
showTabBarController()
}
/// Always represent tabbar controller when authentication state changed
func showTabBarController() {
let tabCoordinator = TabCoordinator(window: window, dependencies: dependencies)
coordinate(to: tabCoordinator)
}
}
TabCoordinator.swift
class TabCoordinator: BaseCoordinator {
typealias Dependencies = HasAPIClient & HasUserManager & HasLanguageManager & HasSpotSocketEngine & HasFuturesSocketEngine
private let window: UIWindow
private let dependencies: Dependencies
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)
})
}
}
答案 0 :(得分:0)