这是我的登录视图控制器到主视图控制器的问题。假设是,一旦我登录,我将进入视图控制器,我可以在上面看到我的导航控制器,并可以在下面选项卡控制器。但是,我在家庭视图控制器中看不到两个控制器了。我创建了一个代码,一旦用户登录,该应用程序将能够从数据库(PHP,MySQLi)获取用户的用户ID,然后将用户ID的值抛给主VC。我成功地将登录值扔到了家庭VC但作为回报,我再也看不到我的导航和标签栏控制器了。这是我的代码供您检查:
//once the user click the login button
DispatchQueue.main.async()
{
//getting the user id of the user
let getNum = responseString
let getBorrowNum = getNum
self.borrowerNum.text = getBorrowNum! as String
//going to home view controller
if self.borrowerNum.text != nil
{
let storyboard : UIStoryboard = UIStoryboard(name: "Home", bundle: nil)
let vc : Home = storyboard.instantiateViewController(withIdentifier: "mainHome") as! Home
vc.teststring = responseString
self.present(vc, animated: true, completion: nil)
}
print("Login Success")
}
答案 0 :(得分:0)
试试这个:
let vc = storyboard.instantiateViewController(withIdentifier: "mainHome") as! Home
self.navigationController!.pushViewController(vc)