问题
After sucessful signin i am opening Tabbar
with follwing code
let mainView = UIStoryboard(name:"Main", bundle: nil)
let tabbar = mainView.instantiateViewController(withIdentifier: "Tabbar") as? Tabbar
tabbar?.modalPresentationStyle = .fullScreen
self.present(tabbar!, animated: true, completion: nil)
Its open Tabbar
with first index selected but first ViewController
also cover the save area ...
and switching between the TabbarItems
make it work fine ...
I am not able to understand why this happening only in one ViewController
on first time open ... and how to tackle that.
Also tried following code but did't work ...
self.edgesForExtendedLayout = []
回答1:
Its not the proper solution its a kind of hack ... I told in Question that its get automatically fixed after switching between TabbarItems
... so i just added Two lines right after opening Tabbar
VC.
tabbar?.selectedIndex = 1
tabbar?.selectedIndex = 0
And know the complete code seems like this.
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let mainView = UIStoryboard(name:"Main", bundle: nil)
let tabbar = mainView.instantiateViewController(withIdentifier: "Tabbar") as? Tabbar
appDelegate.window = UIWindow(frame: UIScreen.main.bounds)
appDelegate.window!.rootViewController = tabbar
appDelegate.window!.makeKeyAndVisible()
tabbar?.modalPresentationStyle = .fullScreen
self.present(tabbar!, animated: true, completion: nil)
tabbar?.selectedIndex = 1
tabbar?.selectedIndex = 0
来源:https://stackoverflow.com/questions/62496238/first-viewcontroller-from-tabbar-cover-the-safe-areastatus-bar