如何从扩展的 iOS 模块显示 viewController

发布于 2025-01-03 09:56:50 字数 109 浏览 6 评论 0原文

我正在使用 Titanium 创建一个模块,该模块在 iOS 中进行了扩展。在该模块中,我正在创建一个 viewController,我想在调用该模块时将其显示在屏幕上。 无法弄清楚..什么是正确的方法。

I am creating an Module in Titanium which is extended in iOS. In that module I am creating a viewController and I want to show it on the screen when i called that module.
Not able to figure it out.. What will be right approach for it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回梦 2025-01-10 09:56:50

在主 TiModule 中,您必须使用 [TiApp app] 作为 UIViewController。但仅仅使用这个就会给你带来线程问题的错误,所以,我们需要创建另一个方法来使用[TiApp app]。 EG

在模块的启动方法中写入:

ENSURE_UI_THREAD(OnMainUI, nil);

这可确保作为参数传递的方法在主线程上运行,因为它具有一些与 UI 相关的操作。如果没有此语句,您将在后台线程中收到 UI 渲染错误。

然后实现以下方法,

- (id) OnMainUI {
   UIViewController *controller = [INITIALIZATION OF CONTROLLER];
   [[TiApp app] showModalController: controller animated: YES];
}

因此,这将打开您创建的控制器。

In the main TiModule, you have to use [TiApp app] for UIViewController. But just using this will give you error of Threading problem, so, we need to create another method to use [TiApp app]. E.G.

In startup method of the module write:

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. Without this statement, you will receive error of UI rendering in background thread.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文