Nativescript addSubview

ぃ、小莉子 提交于 2019-12-11 23:22:34

问题


I'm trying to implement the OpenTok SDK into Nativescript and I've run into an issue that I can't seem to wrap my head around.

Per their documentation (https://tokbox.com/developer/guides/publish-stream/ios/#create_publisher) once you create a publisher object you call:

[self.view addSubview:publisher.view];

I can't figure out how I would tie this into Nativescript, if it's even possible.

My first thought is that I would want a UIView or View element on my page in the XML, then I would call .addView(publisher.view); on that element.

There is a similar question here (Inject pure Java / Obj-C code in NativeScript App) but nothing came of it, the one answer does't provide much help.

I cloned one of OpenTok's sample projects and added their implementation of this call into a gist here: https://gist.github.com/bondydaa/2db355ed45b7e50e4071

You can see at line 117 how they implemented this call. This code raises another question for me in that I'm not sure where _publisherView comes from.

Any help would be greatly appreciated!


回答1:


In Nativescript you can try calling the 'ios' property of the container you are trying to add the component to. This will return the native object.

For example if you have a StackLayout, you can:

var stackLayout = args.object.getViewById("theIdOfTheStackLayout");
stackLayout.ios.addSubview(publisher.view);


来源:https://stackoverflow.com/questions/36228043/nativescript-addsubview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!