ios - Segue to next view controller after successful sign up -
i've searched , searched , searched not found solution. sign works not segue next view controller. heres code:
import uikit import parse import bolts class signupvc: uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { @iboutlet weak var profilepictureiv: uiimageview! @iboutlet weak var firstnametf: uitextfield! @iboutlet weak var lastnametf: uitextfield! @iboutlet weak var newusernametf: uitextfield! @iboutlet weak var newpasswordtf: uitextfield! @iboutlet weak var emailtf: uitextfield! @iboutlet weak var phonenumbertf: uitextfield! @ibaction func setprofilepicture(sender: anyobject) { let mypickercontroller = uiimagepickercontroller() mypickercontroller.delegate = self mypickercontroller.sourcetype = uiimagepickercontrollersourcetype.photolibrary self.presentviewcontroller(mypickercontroller, animated: true, completion: nil) } @ibaction func signupbutton(sender: anyobject) { let spinner: uiactivityindicatorview = uiactivityindicatorview(frame: cgrectmake(0, 0, 150, 150)) uiactivityindicatorview if firstnametf.text != "" && lastnametf.text != "" && newusernametf.text != "" && newpasswordtf.text != "" && emailtf.text != "" && phonenumbertf.text != "" { let newuser = pfuser() if let profilepictureimage = profilepictureiv?.image { let profilepicture = uiimagejpegrepresentation(profilepictureimage, 1)! let profilepictureimagefile = pffile(data: profilepicture) newuser["profilepicture"] = profilepictureimagefile } newuser["firstname"] = firstnametf.text newuser["lastname"] = lastnametf.text newuser.username = newusernametf.text newuser.password = newpasswordtf.text newuser.email = emailtf.text newuser["phonenumber"] = phonenumbertf.text newuser.signupinbackgroundwithblock { (succeeded: bool, error: nserror?) -> void in if let error = error { spinner.startanimating() self.alert("opps", textmessage: (error.localizeddescription)) } else { spinner.startanimating() self.alert("congratualtion!", textmessage: "success, account has been created.") self.performseguewithidentifier("showmessages", sender: self) } } } else { alert("hmm...", textmessage: "if want account, please fill in blanks.") } } override func viewdidload() { super.viewdidload() // additional setup after loading view. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } override func viewwillappear(animated: bool) { self.navigationcontroller!.navigationbar.hidden = false } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) { profilepictureiv.image = info[uiimagepickercontrolleroriginalimage] as? uiimage self.dismissviewcontrolleranimated(true, completion: nil) } func alert(texttitle: string, textmessage: string) { let alertcontroller = uialertcontroller(title: texttitle, message: textmessage, preferredstyle: .alert) alertcontroller.addaction(uialertaction(title: "ok", style: .default, handler: nil)) self.presentviewcontroller(alertcontroller, animated: true, completion: nil) } /* // mark: - navigation // in storyboard-based application, want little preparation before navigation override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { // new view controller using segue.destinationviewcontroller. // pass selected object new view controller. } */ }
if play self.performseguewithidentifier("showmessages", sender: self)
line anywhere else when run program , press signup button directly go in messages view controller without signup required.
as paulw11 said , try remove alert message :-
if let error = error { spinner.startanimating() self.alert("opps", textmessage: (error.localizeddescription)) } else { spinner.startanimating() self.performseguewithidentifier("showmessages", sender: self) }
or can call handler in code.
if let error = error { spinner.startanimating() self.alert("opps", textmessage: (error.localizeddescription)) } else { spinner.startanimating() var alert = uialertcontroller(title: "welcome", message: "login", preferredstyle: uialertcontrollerstyle.alert) alert.addaction(uialertaction(title:"ok", style: .default, handler: { action in self.performseguewithidentifier("showmessages", sender: self) } }
Comments
Post a Comment