[英]MvvmCross iOS similar to IMvxAndroidCurrentTopActivity
I'm trying to create a Plugin in MvvmCross that uses the UIActionSheet. 我正在尝试在MvvmCross中创建一个使用UIActionSheet的插件。 But to use it I need to have the top View in iOS. 但是要使用它,我需要拥有iOS中的顶级View。 I found in Android the IMvxAndroidCurrentTopActivity but i could not find a similar in iOS. 我在Android中找到IMvxAndroidCurrentTopActivity,但在iOS中找不到类似的内容。 Is there anything that i can use like this in iOS? 我在iOS中有什么可以使用的吗?
var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity;
if (activity == null)
{
throw new Exception("Cannot get current top activity");
}
I don't think there is an exact equivalent. 我认为没有确切的等价物。
Plugins like PictureChooser work around this by using IModalHost
from the presenter - eg see https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/PictureChooser/Cirrious.MvvmCross.Plugins.PictureChooser.Touch/MvxImagePickerTask.cs 像PictureChooser这样的插件可以通过使用IModalHost
来解决此问题-例如,请参见https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/PictureChooser/Cirrious.MvvmCross.Plugins.PictureChooser.Touch/MvxImagePicker的.cs
Other plugins rely on static
s or globals - eg see https://github.com/brianchance/MvvmCross-UserInteraction/blob/master/Chance.MvvmCross.Plugins.UserInteraction.Touch/UserInteraction.cs 其他插件依赖于static
或globals-例如,请参见https://github.com/brianchance/MvvmCross-UserInteraction/blob/master/Chance.MvvmCross.Plugins.UserInteraction.Touch/UserInteraction.cs
For your plugin, you could require that users provide a custom interface in their app (eg in the presenter) or you could add something to IModalHost
as a pull request. 对于您的插件,您可以要求用户在其应用程序中(例如在演示者中)提供自定义界面,也可以将某些IModalHost
作为拉取请求添加到IModalHost
中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.