1
votes

I create some project that consists from videoplayer. For Xamarin android I implemented through messaging center.

On android:

Page(xamarin forms) -> (click button and sending message to MainActivity) -> calling MyVideoActivity via intent

With android all works perfectly.

But I am newbie with ios and xamarin ios also.

And I don't know is this real to implement the same in xamarin ios through messaging center ? Also I would like use .xib file(with ui, taken from Xcode). I am not sure how to implement it. I would like to do it through messaging center -> calling custom ViewController with my .xib file. Is it real?

p.s. I've found some example with PageRenderer, but don't investigate it. I am not sure that it will be suitable for me.

1

1 Answers

2
votes

Call the following methods in your MessagingCenter.Subscribe lambda:

XIB-based ViewController:

var vc = new XIBBasedViewController();
// Set any public properties / call methods on your `XIBBasedViewController`
InvokeOnMainThread(() => UIApplication.SharedApplication.Windows[0].RootViewController.PresentViewController(vc, true, null));

Storyboard-based ViewController:

var storyboard = UIStoryboard.FromName("StoryBoardFileNameMinusExtension", null);
var vc = storyboard.InstantiateViewController("AStoryBoardIDAssignedToYourViewController") as AViewControllerSubClass;
// Set any public properties / call methods on your `AViewControllerSubClass`
InvokeOnMainThread(() => UIApplication.SharedApplication.Windows[0].RootViewController.PresentViewController(vc, true, null));

Note: A good place to setup your messaging center subscribes is in the FinishedLaunching of the AppDelegate class.