Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Problem to create a touch plugin

RobertoFonsecaRobertoFonseca BRMember
edited October 2015 in Xamarin.Forms

I'm trying to create a plugin to use touch events in forms.

I'll use iOS as exemple, so i've created the classes, ViewTouch and CrossTouch extended to UIView and Interface respectively

public class ViewTouch : UIView { //The overridden methods here! }

public class CrossTouch : ITouch { //The implementation and others here. }

On the interface I created a single event which is called everytime the overridden touch methods on ViewTouch is executed.

public interface ITouch
      event EventHandler<EventArgs> TouchChanged;

On iOS library I use the Init() method to get the UIView from AppDelegate;
CrossTouch.Init (UIApplication.SharedApplication.KeyWindow.RootViewController.View);

The problem is "How I get the UIView from iOS?" (or maybe the UIViewController), cause the View on init is null.


  • adamkempadamkemp USInsider, Developer Group Leader mod

    What does CrossTouch.Init do? It's not clear to me what the relationship is between your ViewTouch class (a view) and the view passed in to CrossTouch.Init.

    The RootViewController (and the KeyWindow for that matter) will be created in base.FinishedLaunching. The FormsApplicationDelegate class handles that for you. So you would have to put this line after calling base.

Sign In or Register to comment.