UIKit.UIResponder.TouchesBegan Method
Sent when one or more fingers touches the screen.

Syntax

[Foundation.Export("touchesBegan:withEvent:")]
public virtual void TouchesBegan (Foundation.NSSet touches, UIEvent evt)

Parameters

touches
Set containing the touches as objects of type UIKit.UITouch.
evt
The UIEvent that encapsulates all of the touches and the event information.

Remarks

The touches set containing all of the touch events.

If your application tracks the touches starting with this method, it should also override both the UIResponder.TouchesEnded(Foundation.NSSet, UIKit.UIEvent) and UIResponder.TouchesCancelled(Foundation.NSSet, UIKit.UIEvent) methods to track the end of the touch processing.

UIViews by default only receive a single touch event at once, if you want to receive multiple touches at the same time, set the UIView.MultipleTouchEnabled property to true.

If you only want to handle a single touch, the following idiom can be used:

C# Example

public override void TouchesBegan (NSSet touches, UIEvent evt)
{
    var touch = touches.AnyObject as UITouch;

    Console.WriteLine (touch);
}

If you want to handle multiple touches, you can use this idiom:

C# Example

public override void TouchesBegan (NSSet touches, UIEvent evt)
{
    foreach (UITouch touch in touches.ToArray<UITouch> ()){
        Console.WriteLine (touch);
    }
}

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0