Question

I'm trying to create a Plugin in MvvmCross that uses the UIActionSheet. But to use it I need to have the top View in iOS. I found in Android the IMvxAndroidCurrentTopActivity but i could not find a similar in iOS. Is there anything that i can use like this in iOS?

var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity;
if (activity == null)
{
   throw new Exception("Cannot get current top activity");
}
Was it helpful?

Solution

I don't think there is an exact equivalent.

Plugins like PictureChooser work around this by using IModalHost from the presenter - e.g. see https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/PictureChooser/Cirrious.MvvmCross.Plugins.PictureChooser.Touch/MvxImagePickerTask.cs

Other plugins rely on statics or globals - e.g. see 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 (e.g. in the presenter) or you could add something to IModalHost as a pull request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top