实际上,我将导航 Controller 作为根 Controller 嵌入到 main.storyboard 中,我有两个屏幕,一个是登录屏幕,另一个是主页,根据登录凭据,我需要跳过登录屏幕,我需要显示主屏幕。来自appdelegate 我正在做这个跳过它不能正常工作
Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7fadf384c600>.
let storyboard=UIStoryboard.init(name: "Main", bundle: nil)
let navigationController=storyboard.instantiateInitialViewController()
let username=UserDefaultUtil.getString(key: AppConstants.PREF_USERID)
print(username!)
if username != ""
{
window?.rootViewController=navigationController
let sectionController=SectionController(nibName: "SectionController" , bundle: nil)
navigationController?.present(sectionController, animated: true, completion: nil)
}
最佳答案
我猜你正试图在 navigationController 中呈现你的 sectionController,它不是真正的工作方式,试试这个代码:
let navigationController = self.storyboard?.instantiateInitialViewController() as! UINavigationController
并用这个替换现在的:
navigationController.setViewControllers([sectionController], animated: false)
或者只是放下 navigationController 实例化并使用代码创建它并将其设置为 window?.rootViewController
:
let sectionController=SectionController(nibName: "SectionController" , bundle: nil)
let nav = UINavigationController(rootViewController: sectionController)
window?.rootViewController = nav
关于ios - 如何在 ios 中从 appdelegate 呈现不同的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40990712/