문제

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");
}
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top