Upravit

Sdílet prostřednictvím


UIResponder.TouchesBegan(NSSet, UIEvent) Method

Definition

Sent when one or more fingers touches the screen.

[Foundation.Export("touchesBegan:withEvent:")]
public virtual void TouchesBegan (Foundation.NSSet touches, UIKit.UIEvent evt);
abstract member TouchesBegan : Foundation.NSSet * UIKit.UIEvent -> unit
override this.TouchesBegan : Foundation.NSSet * UIKit.UIEvent -> unit

Parameters

touches
NSSet

Set containing the touches as objects of type UITouch.

evt
UIEvent

The UIEvent that encapsulates all of the touches and the event information.

This parameter can be null.

Attributes

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 TouchesEnded(NSSet, UIEvent) and TouchesCancelled(NSSet, 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 MultipleTouchEnabled property to true.

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

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:

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

Applies to