Hyperloop未知或不支持的类型(UIAlertController)

时间:2016-01-26 16:43:09

标签: appcelerator appcelerator-hyperloop appc-hyperloop hyperloop

我正在尝试使用Hyperloop。我正在尝试运行我的项目中的自定义快速脚本(如exmaple中所示)。

这是我的快速代码:

import UIKit

public class MySwiftCode : NSObject {
    func SayHello() {
        let alertController = UIAlertController(title: "iOScreator", message: "Hello, world!", preferredStyle: UIAlertControllerStyle.Alert)
        alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
    }
}

编译时我收到以下错误信息:

[INFO]  Generating metabase for swift MyFramework /Users/ophir/Documents/Appcelerator_Studio_Workspace/HyperloopApp/src/MySwift.swift
Swift Generation failed with unknown or unsupported type (UIAlertController) found while compiling /Users/ophir/Documents/Appcelerator_Studio_Workspace/HyperloopApp/src/MySwift.swift
2016-01-26T16:40:22.195Z | ERROR  | ti run exited with error code 1

UIAlertControllerUIKithttps://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/)的一部分,根据我的理解,使用Hyperloop运行的本机代码无需等待Appcelerator实现它。所以我想知道为什么这段代码没有运行。

1 个答案:

答案 0 :(得分:3)

首先,请确保使用最新的Hyperloop版本(至少1.2.6)。以下示例代码适用于我(在hyperloop-examples存储库中测试):

导入UIKit

public class MySwiftView : UIImageView {
    convenience init () {
        self.init(image: UIImage.init(named:"swift.png"))
    }

    func SayHello() {
        let alertController = UIAlertController(title: "iOScreator", message: "Hello, world!", preferredStyle: UIAlertControllerStyle.Alert)
        alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
    }

}

还要确保使用iOS 8及更高版本运行该应用程序。由于它是非代理API,您需要自己验证它。要将最小目标设置为iOS8,请在tiapp.xml的<ios>部分添加以下密钥:

<min-ios-ver>8.0</min-ios-ver>

相关问题