【问题标题】:Hyperloop unknown or unsupported type (UIAlertController)Hyperloop 未知或不支持的类型 (UIAlertController)
【发布时间】:2016-01-26 16:43:08
【问题描述】:

我正在试用 Hyperloop。我正在尝试运行我在项目中拥有的自定义 swift 脚本(如示例中所示)。

这是我的快速代码:

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

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

【问题讨论】:

    标签: appcelerator appcelerator-hyperloop appc-hyperloop hyperloop


    【解决方案1】:

    首先,请确保使用最新的 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>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      • 2020-02-10
      • 2013-12-12
      • 2014-11-10
      • 2021-09-20
      • 1970-01-01
      • 2021-10-21
      相关资源
      最近更新 更多