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

Syntax

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

Parameters

touches
Set containing the touches as objects of type MonoTouch.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(MonoTouch.Foundation.NSSet, MonoTouch.UIKit.UIEvent) and UIResponder.TouchesCancelled(MonoTouch.Foundation.NSSet, MonoTouch.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 MonoTouch.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: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0