ios - 当显示 UIAlertViewController 时,Viewcontroller 将另一个 View Controller 显示为背景层?

标签 ios swift xcode uialertcontroller

我遇到了一个非常奇怪的问题。当显示 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/

相关文章:

swift - Firebase Crashlytics 未在控制台仪表板中快速显示崩溃报告

Objective-C:阻塞线程直到 NSTimer 完成(iOS)

android - 如何验证已发布的 IOS/Android 应用的应用开发语言?

iphone - iphone中的音乐节拍检测

ios - 一个项目中多个 UIImage+ImageEffects 文件

android - ios 上的 cordova 应用程序中的视频没有声音

c - UnsafeMutablePointer<Int8> 到 UTF8 字符串

swift - 当我选择不同的 UITextField 时如何更改 UIPickerViewData?

ios - 以编程方式定位按钮,结果出乎意料

ios - UIView.convertPoint 没有按预期工作