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

# setViewControllers(_:direction:animated:completion:)

Sets the view controllers to be displayed.

```
func setViewControllers(_ viewControllers: [UIViewController]?, direction: UIPageViewController.NavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil)
```

## Parameters

`viewControllers`

The view controller or view controllers to be displayed.

`direction`

The navigation direction.

`animated`

A Boolean value that indicates whether the transition is to be animated.

`completion`

A block to be called when the page-turn animation completes.

    The block takes the following parameters:

- *finished*: <doc://com.apple.documentation/documentation/Swift/true> if the animation finished; <doc://com.apple.documentation/documentation/Swift/false> if it was skipped.

## Discussion

The view controllers passed to this method are those that will be visible after the animation has completed. Use a data source to provide additional view controllers to which users navigate.

If the transition style is [`UIPageViewController.TransitionStyle.pageCurl`](/documentation/UIKit/UIPageViewController/TransitionStyle-swift.enum/pageCurl), the view controllers to pass in the `viewControllers` parameter depends on the spine location and the value of the [`isDoubleSided`](/documentation/UIKit/UIPageViewController/isDoubleSided) property:

|Spine location                                                                                                                                                                                    |Double sided                                             |What to pass                                                                                                                              |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
|``doc://com.apple.uikit/documentation/UIKit/UIPageViewController/SpineLocation-swift.enum/mid``                                                                                                   |<doc://com.apple.documentation/documentation/Swift/true> |Pass the page to be displayed on the left and the page to be displayed on the right.                                                      |
|``doc://com.apple.uikit/documentation/UIKit/UIPageViewController/SpineLocation-swift.enum/min`` or ``doc://com.apple.uikit/documentation/UIKit/UIPageViewController/SpineLocation-swift.enum/max``|<doc://com.apple.documentation/documentation/Swift/true> |Pass the front of the page to be displayed and the back of the previously-displayed page. The back is used for the page turning animation.|
|``doc://com.apple.uikit/documentation/UIKit/UIPageViewController/SpineLocation-swift.enum/min`` or ``doc://com.apple.uikit/documentation/UIKit/UIPageViewController/SpineLocation-swift.enum/max``|<doc://com.apple.documentation/documentation/Swift/false>|Pass the front of the page to be displayed.                                                                                               |

---

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)