带有 UIViewController 的插件 [英] Plugin with UIViewController
问题描述
有人可以向我解释 Cordova iOS 插件的生命周期吗?
Can somebody explain to me the life-cycle of a Cordova iOS plugin?
特别是,我有一个我正在尝试开发的插件,其中包含一个 UIView
(以及相关的 UIViewController
).
Particularly, I have a plugin I am trying to develop which contains a UIView
(and associated UIViewController
).
我如何从我的扩展 CDVPlugin
类中获取 Cordova UIView
,以便我可以将我的插件作为子视图添加到它(这是它的工作原理吗?).
How do I obtain the Cordova UIView
from my extended CDVPlugin
class, so I can add my plugin as a sub-view to it (is this how it works?).
我想在我的 Cordova 应用程序顶部临时显示我的 UIView
,然后关闭它,返回到我的 JS/HTML 应用程序.
I would like to temporarily show my UIView
on top of my Cordova app, then dismiss it, returning to my JS/HTML app.
推荐答案
如果你想在cordova webview上呈现整个UIViewController(全屏),你可以这样做
If you want to present the whole UIViewController (full screen) over the cordova webview, you can do
[self.viewController presentViewController:yourViewController animated:YES completion:nil];
示例:
如果你只想在cordova webview上添加一个视图,你可以这样做
If you want to add just a view over the cordova webview, you can do
[self.viewController.view addSubview:yourView];
示例:
区别在于,第一种方法显示整个视图控制器,全屏,第二种方法显示可以具有您想要的大小和位置的视图,如果您不使其具有与设备相同的大小screen 用户会在它下面看到你的cordova webview
The diference is, that the first method present the whole view controller, full screen, the second method shows a view that can have the size and position you want, if you don't make it have the same size of the device screen the user will see your cordova webview under it
这篇关于带有 UIViewController 的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!