首页 > 解决方案 > 如何从我的 NativeScript UIView for iOS 中获取指针?

问题描述

我正在从自定义 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

当我给出一个 void 指针时它正在工作,但是该函数正在等待视图显示视频,因此该函数正在完成它的工作,但我在我的 iOS 应用程序上什么也看不到。现在我有我的 UIView :

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

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

 ERROR Error: Value is not a pointer.

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

标签: iosnativescriptnativescript-plugin

解决方案


终于找到了解决方案,说实话有点运气:

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

很简单,但文档并不清楚。希望这可以帮助


推荐阅读