Instance Method

targetViewController(forAction:sender:)

Returns the view controller that responds to the action.

Declaration

func targetViewController(forAction action: Selector, sender: Any?) -> UIViewController?

Parameters

action

The requested action.

sender

The object sending the request.

Return Value

The view controller that handles the specified action or nil if no view controller handles the action.

Discussion

This method returns the current view controller if that view controller overrides the method indicated by the action parameter. If the current view controller does not override that method, UIKit walks up the view hierarchy and returns the first view controller that does override it. If no view controller handles the action, this method returns nil.

A view controller can selectively respond to an action by returning an appropriate value from its canPerformAction(_:withSender:) method.

See Also

Supporting Custom Transitions and Presentations

var transitioningDelegate: UIViewControllerTransitioningDelegate?

The delegate object that provides transition animator, interactive controller, and custom presentation controller objects.

var transitionCoordinator: UIViewControllerTransitionCoordinator?

Returns the active transition coordinator object.

var presentationController: UIPresentationController?

The nearest presentation controller that is managing the current view controller.

var popoverPresentationController: UIPopoverPresentationController?

The nearest popover presentation controller that is managing the current view controller.

var restoresFocusAfterTransition: Bool

A Boolean value that indicates whether an item that previously was focused should again become focused when the item's view controller becomes visible and focusable.