iPhone 10 和 11 在 xcode 11 上运行应用程序后没有足够的高度



所以我有一个内置在 xcode 10.2.1 中的应用程序,然后我后来在 Xcode 11 上运行该应用程序。该应用程序显示黑屏,因为视图没有足够的高度(只有 48.0,为什么???(。所有设备都运行良好,但在iOS 10上运行的iPhone 11和13确实存在错误。

注意:没有使用故事板,该应用程序是在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,但没有奏效。我还尝试使用场景选择退出。

应用委托.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
}

应用协调员.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)
}
}

选项卡协调员.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)
})
}
}

解决方案是这样的。对于那些像我一样陷入这个问题的人。

https://github.com/tonySwiftDev/UITabbar-fixIOS12.1Bug/issues/4

谢谢!

相关内容

  • 没有找到相关文章

最新更新