我是IOS世界的新手。当我切换到一个只有在我登录时才能显示的新视图时,我在更改视图时遇到了麻烦。我在loginfuction中使用:
@IBAction func loginVerification(sender: UIButton!) {
//Check with the cloud
//temporary faking credentials
var user = "n"
var pass = "n"
if usernameLogin.text == user &&
passwordLogin.text == pass
{
println("Correct credentials")
let homeviewcontroller = HomeViewController()
self.presentViewController(homeviewcontroller, animated: true, completion: nil)
}
else
{
println("Wrong credentials!!")
}
}当我按下检查凭证的login按钮时,会触发上述功能。使用上面的线条使视图变为黑色。对如何让它工作有什么建议吗?关于视图之间的导航,有什么我可以遵循的教程吗?请不要对我这么苛刻:)
提前感谢!
发布于 2014-11-12 02:39:59
您好,我会尝试苹果教程-他们写得相当好,并有代码样本。这是我在学习的时候用到的:https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/SecondTutorial.html。本文特别介绍了如何使用故事板和Segues进行导航。如果您查看页面的左侧,您将看到其他教程的链接,这些教程在入门时可能会对您有所帮助。
发布于 2016-04-07 21:13:56
尝试以下代码:
let controller: homeviewcontroller = self.storyboard?.instantiateViewControllerWithIdentifier("homeviewcontroller") as! homeviewcontroller
self.presentViewController(controller, animated: true, completion: nil)
@IBAction func loginVerification(sender: UIButton!) {
//Check with the cloud
//temporary faking credentials
var user = "n"
var pass = "n"
if usernameLogin.text == user &&
passwordLogin.text == pass
{
println("Correct credentials")
let controller: homeviewcontroller = self.storyboard?.instantiateViewControllerWithIdentifier("homeviewcontroller") as! homeviewcontroller
self.presentViewController(controller, animated: true, completion: nil)
}
else
{
println("Wrong credentials!!")
}
}https://stackoverflow.com/questions/26871439
复制相似问题