gpt4 book ai didi

ios - 用另一个 UIAlertController 替换 UIAlertController

转载 作者:搜寻专家 更新时间:2023-11-01 06:23:06 27 4
gpt4 key购买 nike

我有一个 Parse Sign Up 和一个 UIAlertController,我希望 UIAlertController 显示一个指示器,但在注册出现错误时被另一个 UIAlertController 解雇。

我有几个注册失败的案例,所有这些都在添加带有指示器的 UIAlertController 之前工作。当注册成功并且正确关闭时,指示器警报 Controller 工作正常。

//create an alert controller
let pending = UIAlertController(title: "Creating New User", message: nil, preferredStyle: .Alert)

//create an activity indicator
let indicator = UIActivityIndicatorView(frame: pending.view.bounds)
indicator.autoresizingMask = .FlexibleWidth | .FlexibleHeight
//add the activity indicator as a subview of the alert controller's view
pending.view.addSubview(indicator)
indicator.userInteractionEnabled = false // required otherwise if there buttons in the UIAlertController you will not be able to press them
indicator.startAnimating()
self.presentViewController(pending, animated: true, completion: nil)

这是注册的代码,这个有效

        if signUpError == nil {
println("Sign Up Successful")
// Keep track of the installs of our app
var installation: PFInstallation = PFInstallation.currentInstallation()
installation.addUniqueObject("Reload", forKey: "channels")
installation["user"] = PFUser.currentUser()
installation.saveInBackground()


// to stop the uialertviewcontroller once sign up successful
pending.dismissViewControllerAnimated(true, completion: {
self.performSegueWithIdentifier("goToAppFromSignUp", sender: self)

})

}

这就是我被困的地方,这只是其中一种情况,如果我能让它工作,我可以为其他人做。

        else {
println("Error Sign Up")


//If email has been used for another account kPFErrorUserEmailTaken
if(signUpError!.code == 203) {

let alertController = UIAlertController(title: "Sign Up Failed", message: "Sorry! Email has been taken! ", preferredStyle: .Alert)


let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
// ...
}
alertController.addAction(OKAction)



self.presentViewController(alertController, animated: true) {
// ...
}
}

我的想法是关闭 UIAlertController 并在完成 block 中显示下一个

pending.dismissViewControllerAnimated(true, completion: {
self.presentViewController(alertController, animated: true) {
// ...
}

})

但应用程序在挂起的警报 Controller (带有指示器的 Controller )上卡住。 已经呈现(null)

有什么想法吗?谢谢。

最佳答案

尝试关闭挂起的警报并在没有动画的情况下显示下一个警报。

pending.dismissViewControllerAnimated(false, completion: nil)
self.presentViewController(alertController, animated: false, completion: nil)

关于ios - 用另一个 UIAlertController 替换 UIAlertController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29792956/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com