xcode - 如何使用 UIAlertAction 处理程序 : 转到另一个 Storyboard

标签 xcode swift

当用户使用 UIAlertController 单击按钮时,我会打开一个模式弹出窗口。

let agreeAction = UIAlertAction(title: "Agree", style: .Default, handler: nil)

当前处理程序设置为 nil,但我希望它将用户带到另一个 Storyboard中的 View Controller 。我尝试了以下似乎不起作用的方法。

handler: UIViewController *theInitialViewController = [secondStoryBoard otherViewController];

任何方向或建议将不胜感激。

最佳答案

handler 参数是一个接受 UIAlertAction 并返回 Void 的 block 。因此,您的处理程序参数应如下所示:

{(alert: UIAlertAction!) in
    self.performSegueWithIdentifier("segueId", sender: self);
})

供将来引用:UIAlertController Class Reference

关于xcode - 如何使用 UIAlertAction 处理程序 : 转到另一个 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28889701/

相关文章:

ios - 使用 cocoapods swift 的链接器命令失败,退出代码为 1(使用 -v 查看调用)

ios - 无法在 SpriteKit 中获取 skAudioNode 的 3D 音频效果

ios - 编码问题。转换为可读字符串

ios - 即使有内容,View Controller 也会变黑

swift - 如何创建全局变量?

xcode - 如何在 mac 的终端中使用 g++?

objective-c - 仪器内存警告调试

ios - React-native Xcode 错误 : "Thread 1: signal SIGABRT"

ios - Swift 2.3 会与 iOS 10 兼容吗?

ios - 如何从 tableView 方法中的请求中获取行数?