使用 UIAlertController 操作以编程方式 Link 嵌入 UIViewController

Using UIAlertController Action To Programatically Link To Embedded UIViewController

用户当前在 ViewController 上 Modally

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

像这样:

这是我的相关代码片段:

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 按钮时,没有任何反应。

我哪里错了?

提前致谢Sirs/Mesdames;)

这样写。

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;
}