Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将映像添加到UIAlertController_Ios_Swift_Uialertcontroller_Unrecognized Selector - Fatal编程技术网

Ios 将映像添加到UIAlertController

Ios 将映像添加到UIAlertController,ios,swift,uialertcontroller,unrecognized-selector,Ios,Swift,Uialertcontroller,Unrecognized Selector,我想向UIAlertController添加一个映像。图像不需要在按钮上,只显示在控制器的中间。我的代码如下所示,但由于消息“未识别的选择器已发送到实例”而崩溃 不幸的是,苹果不允许我们向UIAlertController或UIAlertView添加图像。这些API仅限于苹果的人机界面指南 如果您真的需要在类似于UIAlertController-的对话框中使用图像,我建议您尝试使用类似以下内容。什么是无法识别的选择器?如果不可能,则不可能!将不得不使用一个视图控制器,然后…有一种方法可以做到这

我想向UIAlertController添加一个映像。图像不需要在按钮上,只显示在控制器的中间。我的代码如下所示,但由于消息“未识别的选择器已发送到实例”而崩溃


不幸的是,苹果不允许我们向
UIAlertController
UIAlertView
添加图像。这些API仅限于苹果的人机界面指南


如果您真的需要在类似于
UIAlertController
-的对话框中使用图像,我建议您尝试使用类似以下内容。

什么是无法识别的选择器?如果不可能,则不可能!将不得不使用一个视图控制器,然后…有一种方法可以做到这一点
func showAlert () {

    let alert = UIAlertController(title: "Title of Alert",
        message: "none",
        preferredStyle:UIAlertControllerStyle.ActionSheet)

    // add an image
    let image = UIImage(named: "example")
    var imageView = UIImageView(image: image)
    imageView.frame = CGRectMake(0, 0, 100, 100)

    var imageAction = UIAlertAction(title: "", style:.Default, handler: nil)
    imageAction.setValue(imageView, forKey: "image")
    alert.addAction(imageAction)

    // add a continue button
    var action = UIAlertAction(title: "Continue", style:.Default, handler: {(alert:UIAlertAction!) in self.continue() })
    alert.addAction(action)

    // show the UIAlertController
    self.presentViewController(alert, animated: true, completion: nil)

}