<!--
{
  "availability" : [
    "iOS: 6.0.0 - 9.0.0",
    "iPadOS: 6.0.0 - 9.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "tvOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/forUnwindSegueAction(_:from:withSender:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)viewControllerForUnwindSegueAction:fromViewController:withSender:"
  },
  "title" : "forUnwindSegueAction(_:from:withSender:)"
}
-->

# forUnwindSegueAction(_:from:withSender:)

Called when an unwind segue action wants to search a container’s children for a view controller to handle the unwind action.

```
func forUnwindSegueAction(_ action: Selector, from fromViewController: UIViewController, withSender sender: Any?) -> UIViewController?
```

## Parameters

`action`

The action that triggered the unwind action.

`fromViewController`

The view controller that is the source of the unwinding action.

`sender`

The object that initiated the action.

## Return Value

The view controller that wants to handle the unwind action.

## Discussion

A custom container view controller should override this method and use it to search its children for a view controller to handle the unwind action. It does this by invoking the [`canPerformUnwindSegueAction(_:from:withSender:)`](/documentation/UIKit/UIViewController/canPerformUnwindSegueAction(_:from:withSender:)) method on each child. If a view controller wants to handle the action, your method should return it. If none of the container’s children want to handle the unwind action, invoke the super’s implementation and return the result of that method.

---

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)