gpt4 book ai didi

ios - 使用 UIAlertController 操作以编程方式链接到嵌入式 UIViewController

转载 作者:行者123 更新时间:2023-11-29 00:58:18 25 4
gpt4 key购买 nike

用户当前在呈现的 ViewController 上 Modally .

我正在尝试连接 UIAlertViewController 的 OK以编程方式链接到 UIViewController 的按钮操作嵌入 UINavigationController .

像这样:

enter image description here这是我的相关代码片段:

func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {

....// some code

case .Restored:

....// some code
let alert = UIAlertController(title: "Thank You!", message: "You now have FULL ad-free Access", preferredStyle: UIAlertControllerStyle.Alert)
let OKAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { (action:UIAlertAction) in
// Goto Main Page:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("MainMainViewController");
self.navigationController?.presentViewController(vc, animated: true, completion: nil)
}
alert.addAction(OKAction)
self.presentViewController(alert, animated: true, completion: nil)

break;

default:
break;
}

本质上,当用户恢复购买(或成功)时,我希望他们点击 OK将它们发送到另一个 ViewController - MainMainViewcontroller .

但是当我点击 OK按钮,没有任何反应。

我哪里错了?

在此先感谢亲切的先生/女士们;)

最佳答案

这样写。

func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {

....// some code

case .Restored:

....// some code
let alert = UIAlertController(title: "Thank You!", message: "You now have FULL ad-free Access", preferredStyle: UIAlertControllerStyle.Alert)
let OKAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { (action:UIAlertAction) in
// Goto Main Page:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let navVC = storyboard.instantiateViewControllerWithIdentifier("Navigation");
self.presentViewController(navVC, animated: true, completion: nil)
}
alert.addAction(OKAction)
self.presentViewController(alert, animated: true, completion: nil)

break;

default:
break;
}

关于ios - 使用 UIAlertController 操作以编程方式链接到嵌入式 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37351942/

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