ios - 如何在 UITableViewCell 中使用 UIAlertController

标签 ios swift tableview uialertcontroller

如何在 TableViewCell 中使用 UIAlertController?

给我一​​个错误does not have a member called "presentViewController"

我的 TableViewController 被命名为“OrdensCompraTableViewController”

我的函数:

@IBAction func telefonarCliente(sender: AnyObject) {

    var alert = UIAlertController(title: "Fotos em falta!", message: "Tem de introduzir 6 fotos.", preferredStyle: UIAlertControllerStyle.Alert)
    alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))


    self.presentViewController(alert, animated: true, completion: nil)

    if let phoneCallURL:NSURL = NSURL(string: "tel://") {
        let application:UIApplication = UIApplication.sharedApplication()
        if (application.canOpenURL(phoneCallURL)) {
            application.openURL(phoneCallURL);
        }
    }
}

最佳答案

使用 telprompt://123456789 而不是创建 UIAlertController 在调用电话号码之前提示用户。

关于ios - 如何在 UITableViewCell 中使用 UIAlertController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32235616/

相关文章:

arrays - 全局更改对象值

swift - 解析 : How do I get data from Parse that will be displayed in different unique view controllers

ios - 加载从 Parse 数据类添加的新单元格

iOS UITableView 部分与 fetchedResultsController 混淆

ios - FCM 在 iPhone 8 前台模式下无法接收

ios - 使用标签栏 Controller-> Nav controller -> View Hierarchy 从 app delegate 呈现 View - iOS Swift

swift - 获取 Codable(或 Decodable)中的所有 key

ios - 通过带约束的自调整大小来展开和折叠 TableView 单元格

ios - swift 非空函数应该在 guard let 中返回一个值

ios - 无法停止在模拟器中执行Xcode应用程序?