---
title: AVCaptureDeviceDirectionCoordinator
framework: AVKit
role: symbol
role_heading: Class
platforms: [iOS 27.1+, iPadOS 27.1+]
path: avkit/avcapturedevicedirectioncoordinator
---

# AVCaptureDeviceDirectionCoordinator

An object that tracks the direction each camera faces in relation to a view.

## Declaration

```swift
class AVCaptureDeviceDirectionCoordinator
```

## Mentioned in

Choosing a camera by the direction it faces

## Overview

Overview A coordinator reports the direction each camera faces in relation to one view of your interface. It groups the cameras into the ones that face toward the person looking at that view, and the ones that face away. On a device with more than one display, a camera can change direction as the person opens, closes, or turns the device. The same camera captures that person in one configuration and the scene beyond the view in another. The position property is a fixed characteristic of the camera hardware, and it doesn’t change as the device does. Don’t read the direction a camera faces from it, because two cameras that report different positions can face the same way. Only a coordinator reports direction, and reports it again each time it changes. Create a coordinator on the main actor, and pass the view that shows your preview and the device types your app captures from. The view is the coordinator’s frame of reference rather than something it draws into. Hold a strong reference to the coordinator for as long as that view stays onscreen. Include your rear cameras alongside your front ones, because a rear camera can end up facing the person when they open or close the device, or when your view moves to a display that faces in the opposite direction. important: If your app shows a preview on more than one display at once, create a coordinator for each view. Each reports direction in relation to its own view, so the same camera can be forward facing to one and backward facing to the other. Read deviceDirections for the direction of each camera at that moment, and pass a change handler to learn about later changes. The coordinator calls the handler on the main actor soon after you create it, then again on every change. In the following example, an observer creates a coordinator and hands each new forward-facing camera to the object that owns the capture session: import AVKit

@MainActor final class DirectionObserver {

private var coordinator: AVCaptureDeviceDirectionCoordinator?

func startObserving(previewView: UIView) {         coordinator = AVCaptureDeviceDirectionCoordinator(             view: previewView,             deviceTypes: [.builtInOuterUltraWideCamera, .builtInInnerUltraWideCamera]         ) { [weak self] deviceDirections in             // Capture from the first camera that faces the person using the app.             guard let descriptor = deviceDirections.forwardFacingDeviceDescriptors.first else { return }             self?.selectCamera(with: descriptor)         }     } } The map names each camera with an AVCaptureDeviceDescriptor, which identifies a camera without being one. Pass the descriptor to the actor that owns your capture session, and create the AVCaptureDevice there, because configuring a capture device doesn’t belong on the main actor.

## Topics

### Creating a coordinator

- [init(view:deviceTypes:changeHandler:)](avkit/avcapturedevicedirectioncoordinator/init(view:devicetypes:changehandler:).md)

### Reading the camera directions

- [deviceDirections](avkit/avcapturedevicedirectioncoordinator/devicedirections.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Camera facing direction

- [Choosing a camera by the direction it faces](avkit/choosing-a-camera-by-the-direction-it-faces.md)
- [AVCaptureDeviceDirectionMap](avkit/avcapturedevicedirectionmap.md)
- [AVCaptureDeviceDescriptor](avkit/avcapturedevicedescriptor.md)
