[英]How to display a viewController from an extended iOS module
I am creating an Module in Titanium which is extended in iOS. 我正在用Titanium创建一个在iOS中扩展的模块。 In that module I am creating a viewController and I want to show it on the screen when i called that module.
在该模块中,我正在创建一个viewController,我想在调用该模块时在屏幕上显示它。 Not able to figure it out.. What will be right approach for it.
无法弄清楚。什么是正确的方法。
In the main TiModule, you have to use [TiApp app]
for UIViewController. 在主TiModule中,必须对UIViewController使用
[TiApp app]
。 But just using this will give you error of Threading problem, so, we need to create another method to use [TiApp app]
. 但是仅使用此方法将给您带来线程问题的错误,因此,我们需要创建另一种方法来使用
[TiApp app]
。 EG 例如
In startup method of the module write: 在模块的启动方法中编写:
ENSURE_UI_THREAD(OnMainUI, nil);
ENSURE_UI_THREAD(OnMainUI,nil);
This ensures that the method which is passed as an argument runs on Main Thread because it has some UI related operation. 这样可以确保作为参数传递的方法在主线程上运行,因为它具有一些与UI相关的操作。 Without this statement, you will receive error of UI rendering in background thread.
如果不使用此语句,您将在后台线程中收到UI渲染错误。
Then implement following method, 然后执行以下方法,
- (id) OnMainUI {
UIViewController *controller = [INITIALIZATION OF CONTROLLER];
[[TiApp app] showModalController: controller animated: YES];
}
So, this will open up the controller, which you created. 因此,这将打开您创建的控制器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.