简体   繁体   English

在Titanium iOS模块中添加子视图

[英]Adding subview in Titanium iOS module

I have created iOS module in Titanium. 我已经在Titanium中创建了iOS模块。 This module includes my own framework written in native objective c. 这个模块包括我自己用原生目标c编写的框架。 Everything looks fine, but there is one issue. 一切看起来不错,但是有一个问题。 One of the methods i've ported from my framework through module, takes a UIView and adds to it another uiview as a subview. 我从框架通过模块移植的方法之一是采用UIView并将另一个uiview作为子视图添加到其中。 This subview contains a UIView with a UIButton. 该子视图包含带有UIButton的UIView。 Problem is that sometimes subview appeares on the screen but without label on the button, i have to click the button, then the label appeares. 问题是有时子视图出现在屏幕上,但是按钮上没有标签,我必须单击按钮,然后标签才会出现。 But in some situations (it depends when i call this method from the module in javascript), subview doesn't appeare at all, but it is actually there because when i tap on the place where it should be, button's click event handler is being called. 但是在某些情况下(这取决于我何时从javascript中的模块调用此方法),根本没有出现子视图,但实际上它在那里,因为当我点击应有的位置时,按钮的click事件处理程序就会被显示。叫。 I have no idea what is wrong (maybe something with layer). 我不知道出什么问题了(也许是有问题的)。 When i use my framework in a native ios app, everything is working fine. 当我在本机ios应用程序中使用框架时,一切工作正常。

Could someone help me with that? 有人可以帮我吗?

Subview has to be added on main thread, so i have used a method: 子视图必须在主线程上添加,因此我使用了一种方法:

[self performSelectorOnMainThread: withObject: waitUntilDone:];

Now everything appeares perfectly. 现在,一切看起来都很完美。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM