ios - Parse switching view controller on sucessful login -
after user logs in sucessfully, need switch view controllers timeline section of app, going tab bar view controller 5 different tabs @ bottom. here code have far, works , connected parse database have setup. import uikit import parse
class loginviewcontroller: uiviewcontroller { @iboutlet var usernamefield: uitextfield! @iboutlet var passwordfield: uitextfield! override func viewdidload() { super.viewdidload() // additional setup after loading view. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func logintapped(sender: anyobject) { let username = usernamefield.text let password = passwordfield.text pfuser.loginwithusernameinbackground(username, password:password) { (user: pfuser?, error: nserror?) -> void in if user != nil { println("success") } else { var loginerror:uialertview = uialertview(title: "invalid login", message: "i did not recognize credentials. try again?", delegate: self, cancelbuttontitle: "dismiss") loginerror.show() } } } @ibaction func closetapped(sender: anyobject) { dismissviewcontrolleranimated(true, completion: nil) } }
in line println("sucessful"), instead of printing out sucessful login need switch timeline home (the tab bar view controller).
use segue transition new view controller if login successful:
if user != nil { self.performseguewithidentifier("successfulloginpage", sender: self)
}
Comments
Post a Comment