我遇到了一个非常奇怪的问题。当显示 UIAlertController
时,会在当前 View Controller 的背景层中显示 Previous UIAlertController
。我无法发布该屏幕的屏幕截图。
下面是显示 UIAlertController
func showActionAlertView(alertData:[String],vc:UIViewController,singleType:Bool) -> Void {
let Alert = UIAlertController(title: alertData.first, message: NSLocalizedString(alertData[1], comment: ""), preferredStyle: UIAlertControllerStyle.alert)
Alert.addAction(UIAlertAction(title: alertData[2], style: .default, handler: { (action: UIAlertAction!) in
self.delegate?.okAction(controller: vc)
}))
if !singleType
{
Alert.addAction(UIAlertAction(title: alertData.last, style: .cancel, handler: { (action: UIAlertAction!) in
print("Handle Cancel Logic here")
self.delegate?.cancelAction(controller: vc)
}))
}
vc.present(Alert, animated: true, completion: nil)
}
谢谢
最佳答案
您必须在同一 View Controller 中访问上述函数,其中 vc 的值也需要相同。
class OneVC: UIViewController{
//Inside viewDidLoad
// value for vc should be given same as of present class name (OneVC)
showActionAlertView(alertData:[String], vc:OneVC, singleType:Bool) -> Void
}
关于ios - 当显示 UIAlertViewController 时,Viewcontroller 将另一个 View Controller 显示为背景层?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41887684/