我在标题中使用带有 Map 的 UICollectionView。
我想处理核心位置错误。我有 3 种错误类型,对于其中两种,我想显示一个 UIAlertView
。
但是我得到一个错误,因为 UICollectionViewCell
没有名为 presentViewController
的成员。
func locationUnknown() {
var alert = UIAlertController(title: "Location Unknown", message: "Please try again later.", preferredStyle: UIAlertControllerStyle.Alert)
let alertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) -> Void in
})
alert.addAction(alertAction)
self.presentViewController(alert, animated:true, completion: nil)
}
如何将此 UIAlertView
发送到 UICollectionView
的屏幕?
最佳答案
使用窗口的 Root View Controller 来呈现警报:
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
关于ios - 如何从 UICollectionViewCell 呈现一个 AlertView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32390726/