【发布时间】:2015-05-06 15:08:32
【问题描述】:
我有下面的代码,一旦用户注册他们的帐户,它就会将我带到登录页面。我想不通的是如何在创建帐户时弹出警报框,并且用户停留在注册页面上,直到他们单击警报框底部的“登录”按钮,然后将他们重定向到登录页。关于如何在下面更改我当前的代码有什么想法吗?
// Display alert message with confirmation
var alert = UIAlertController(title: "Registration Successful", message: "You may now login. Thank You!", preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction(title:"Login", style: UIAlertActionStyle.Default){ action in
self.dismissViewControllerAnimated(true, completion: nil)
}
alert.addAction(okAction)
}
func displayAlertMessage(userMessage:String) {
var alert = UIAlertController(title:"Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction(title:"Ok", style: UIAlertActionStyle.Default, handler: nil)
alert.addAction(okAction)
self.presentViewController(alert, animated: true, completion: nil)
}
【问题讨论】:
-
如何注册用户?我猜您的服务器会在创建用户后发回“成功”消息。
-
目前它只是将数据保存在本地,因为我还没有将它发送到数据库。只是想先完成格式化。