简体   繁体   中英

MvvmCross: show a built-in iOS ViewController

I want to present an MCBrowserViewController (a "native" iOS 7 View Controller) in a Xamarin.iOS app using MvvmCross. It appears that there are two ways to accomplish this (as detailed in Integrating third party controller with MVVMCross on MonoTouch ):

  1. create a Custom Presenter
  2. inherit from MCBrowserViewController to provide an EventSource -ViewController, and inherit from the EventSource -ViewController to add the Mvx BindingContext

I have tried 1 and 2 above (I suspect that 2 is the more correct approach?), but I am not able to actually present the MCBrowserViewController . I have watched a range of the "N+1 Days of MvvmCross" tutorials but I can't seem to find a tutorial specifically on this.

Any help will be greatly appreciated! I can post the code I wrote in implementing approach 2 above if it will help.

THe EventSource inheritance approach you describe is the standard way for cases where you want to build upon the functionality of a pre-built controller.

However, if MCBrowserViewController is just a modal view which you want to "pop up" and use "as is" from within an existing view, then you can just display this view from within your app.

This is how the Tweet sharing plugin works - https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/Share/Cirrious.MvvmCross.Plugins.Share.Touch/MvxShareTask.cs

And similarly how the image picker works - https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/PictureChooser/Cirrious.MvvmCross.Plugins.PictureChooser.Touch/MvxImagePickerTask.cs (although this code is a little more complicated to read)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM