当我从Appdelegate检查并调用Viewcontroller时,我的应用程序显示导航栏上方的空白区域我不知道是什么原因。
这里我给出了代码和屏幕截图。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let checkUserid = UserDefaults.standard.value(forKey: "USERID")
if checkUserid != nil {
print(checkUserid!)
let mainStoryboard = UIStoryboard(name: "Main" , bundle: nil)
let revealViewController = mainStoryboard.instantiateViewController(withIdentifier: "RevealViewController") as? SWRevealViewController
let navigationController = UINavigationController(rootViewController: revealViewController!)
navigationController.navigationBar.isTranslucent = false
window!.rootViewController = navigationController
window!.makeKeyAndVisible()
}
else
{
let mainStoryboard = UIStoryboard(name: "Main" , bundle: nil)
let loginViewController = mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
let navigationController = UINavigationController(rootViewController: loginViewController)
navigationController.navigationBar.isTranslucent = false
window!.rootViewController = navigationController
window!.makeKeyAndVisible()
}
}
答案 0 :(得分:1)
我相信您需要隐藏默认导航栏。
尝试添加以下代码:
navigationController.isNavigationBarHidden = true