簡體   English   中英

登錄后,情節提要在主控制器上返回nil

[英]Storyboard returns nil on main controller after login

我使用的是一個名為Main Storyboard,當我嘗試從登錄屏幕重定向(推送)到主屏幕時,在ViewDidLoad主屏幕上,我得到了self.storyboardnil因此UI扭曲(視圖,按鈕,標簽是更改其位置)。 我經常遇到此問題,但並非每次都遇到。

誰能幫助我,將不勝感激。

let sb = UIStoryboard(name: "Main", bundle: nil)
let moveController = sb.instantiateViewController(withIdentifier: "StartViewController ") as! StartViewController 
self.navigationController?.pushViewController(moveController, animated: true)

請檢查您已經正確設置了兩者,因為我已完成查看圖像

請嘗試以下code

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    if storyboard != nil{
           let VC = storyboard.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
           self.navigationController?.pushViewController(VC, animated: true)
    }

如果不告訴我,希望您能找到解決方案

嘗試這個

let startViewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "StartViewController") as? StartViewController
self.navigationController?.pushViewController(startViewController!, animated: true)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM