<!--
{
  "availability" : [
    "iOS: 3.2.0 -",
    "iPadOS: 3.2.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIView/addGestureRecognizer(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIView(im)addGestureRecognizer:"
  },
  "title" : "addGestureRecognizer(_:)"
}
-->

# addGestureRecognizer(_:)

Attaches a gesture recognizer to the view.

```
func addGestureRecognizer(_ gestureRecognizer: UIGestureRecognizer)
```

## Parameters

`gestureRecognizer`

An object whose class descends from the [`UIGestureRecognizer`](/documentation/UIKit/UIGestureRecognizer) class. This parameter must not be `nil`.

## Discussion

Attaching a gesture recognizer to a view defines the scope of the represented gesture, causing it to receive touches hit-tested to that view and all of its subviews. The view establishes a strong reference to the gesture recognizer.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)