swift - UIAlertAction 在存档并导出为临时文件后不执行操作

标签 swift ios8.1 uialertaction

我正在创建警报以响应发现特定的 BLE 特征。此警报有 2 个 UIAlertAction 按钮。从 Xcode (v 6.1.1 6A2008a) 构建时,每个按钮都会正确执行其操作,但使用临时配置文件进行存档和导出时,一个按钮将执行其操作,但另一个按钮不会。

一些代码:

let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)

        let okAction = UIAlertAction(title: "OK", style: .Default) {
            (action) in
            debugData.addToLog("OK button pressed")
        }
        let cancelAction = UIAlertAction(title: "Not Now", style: .Default) {
            (action) in
            debugData.addToLog("Not Now button pressed")
        }
        alertController.addAction(okAction)
        alertController.addAction(cancelAction)
        debugData.addToLog("Building alert")
        appDelegate.nav.presentViewController(alertController, animated: true, completion: nil)

debugData 进入一个隐藏 View ,我使用 UIGesture 来显示该 View 。 Xcode 的输出将显示 Building AlertOK ButtonPressedNot NowbuttonPressed,但存档和导出将仅显示 Buildingalert code> 和 未按下按钮

有什么想法吗?

最佳答案

似乎进入项目“目标”>“build设置”>“Swift 编译器 - 代码生成”>“优化级别”并将“发布”设置为 None [-Onone]将使这两个操作正确执行。似乎是 Swift 编译器错误。

关于swift - UIAlertAction 在存档并导出为临时文件后不执行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28618825/

相关文章:

ios - 使单元格粘在表格 View 的底部

swift - 带有 AWS Cookie 的 AVPlayer 使用 AirPlay

objective-c - 如何更改 UIAlertAction 字体?

ios - Xcode 6.1 构建在设备上崩溃

iOS 8 iPad AVCaptureMovieFileOutput 在录制 13 - 14 秒后丢失/丢失/从未获得音轨

swift - 使用 UIAlertAction Xcode 7.3 beta 的控制台出错

string - 是否可以为 NSString 设置自定义字体和大小?

ios - "Sign in with email"FirebaseUI 形式没有出现在我的屏幕上

swift 错误 "static member cannot be used on instance of type"

ios - 使用 iOS 8.1 在 iPad 上缩放相机时的 UIImagePickerController 问题