swift 显示UIAlertViewController
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 显示UIAlertViewController相关的知识,希望对你有一定的参考价值。
func showAlertControllerWithTitle(title: String, message: String,actions: [String], alertStyle: UIAlertControllerStyle, callback:@escaping (_ actionIndex: Int) -> Void) {
let alertController : UIAlertController = UIAlertController(title: title, message: message, preferredStyle: alertStyle)
for title in actions{
let action : UIAlertAction!
if title.caseInsensitiveCompare("cancel") == ComparisonResult.orderedSame {
action = UIAlertAction(title: title, style: .cancel, handler: { (action) in
callback(actions.index(of: title)!)
})
} else {
action = UIAlertAction(title: title, style: .default, handler: { (action) in
callback(actions.index(of: title)!)
})
}
alertController.addAction(action)
}
self.window?.topMostController()?.present(alertController, animated: true, completion: nil)
}
以上是关于swift 显示UIAlertViewController的主要内容,如果未能解决你的问题,请参考以下文章
swift 3 - 未显示子类视图控制器
swift [Swift]在当前弹出窗口中显示警报(SimpleTransitioningDelegate)
如何检查单元格是不是已显示 Swift
Swift - 更新/刷新显示时间的标签
UIWebView 不显示(Swift)
[Swift]Swift图片显示方式设置,控件UIImageView的contentMode属性设置