如何从我的NativeScript UIView for iOS获取指针?

时间:2019-03-11 15:22:03

标签: ios nativescript nativescript-plugin

我正在通过自定义NativeScript插件集成iOS框架(Vidyo https://developer.vidyo.io/#/documentation/4.1.25.30)。我可以从我的插件实例化iOS类,但无法正确调用此iOS函数:

(id) init:(void*)view RemoteParticipants:(unsigned int)remoteParticipants LogFileFilter:(const char*)logFileFilter LogFileName:(const char*)logFileName

通过nativescript命令

TNS_DEBUG_METADATA_PATH="$(pwd)/metadata" tns build ios

我能够看到NativeScript正在等待的签名:

- Name:            'init:ViewStyle:RemoteParticipants:LogFileFilter:LogFileName:'
        JsName:          initViewStyleRemoteParticipantsLogFileFilterLogFileName
        Filename:        [...].h
        Module:          
        [...]
        Type:            Method
        Signature:       
          - Type:            Instancetype
          - Type:            Pointer
            PointerType:     
              Type:            Void
          - Type:            Enum
            Name:            VCConnectorViewStyle
          - Type:            UInt
          - Type:            CString
          - Type:            CString

当我给出一个空指针时,它正在工作,但是该函数正在等待视图显示视频,因此该函数正在执行其工作,但是我在iOS应用程序上看不到任何东西。现在我有了UIView:

this.nativeView = UIView.alloc().initWithFrame(UIScreen.mainScreen.bounds)
initViewStyleRemoteParticipantsLogFileFilterLogFileName(this.nativeView, [...]) 

它不起作用,因为我有一个错误:

 ERROR Error: Value is not a pointer.

问题:如何从UIView中获取指针?

1 个答案:

答案 0 :(得分:1)

最后找到了解决方案,说实话,有些运气:

this.nativeView = UIView.alloc().initWithFrame(UIScreen.mainScreen.bounds)
let ref = new interop.Reference(interop.Pointer, this.nativeView)
initViewStyleRemoteParticipantsLogFileFilterLogFileName(ref, [...])

非常简单,但是文档尚不清楚。希望这会有所帮助