注释视图可以显示在UIAlertController中吗?

时间:2018-12-04 23:29:07

标签: ios swift

我在iOS中为距离大于200米的地方创建了警报功能。它确实弹出了。但是我想知道是否可以在与苹果ID相似的警报框中放入注释视图。我不知道该怎么做。我在下面附加了我的代码。

 func creatAlert (title:String, message:String, locations: [[String : Any]]) {
        let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
        alert .addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.default, handler: { (action) in
            alert.dismiss(animated: true, completion: nil)
            print("Yes")
        }))
        alert.addAction(UIAlertAction(title: "No", style: UIAlertActionStyle.default, handler: { (action) in
            alert.dismiss(animated: true, completion: nil)
            print("No")
        }))

        alert.addAction(UIAlertAction(title: "", style: UIAlertActionStyle.default, handler: { (action) in
            for location in locations {
                let annotations = MKPointAnnotation()
                annotations.title = location["title"] as? String
                annotations.coordinate = CLLocationCoordinate2D(latitude: (location["latitude"] as? CLLocationDegrees)!, longitude: (location["longtitude"] as? CLLocationDegrees)!)
                self.mapView.addAnnotation(annotations)
            }
        }))

        self.present(alert, animated: true, completion: nil)
    }

我附上了截图图片。该地图未显示在警报框中。 enter image description here

0 个答案:

没有答案