View in English

  • Apple 开发者
    • 入门汇总

    探索“入门汇总”

    • 概览
    • 学习
    • Apple Developer Program

    及时了解最新动态

    • 最新动态
    • 开发者你好
    • 平台

    探索“平台”

    • Apple 平台
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    • App Store

    精选

    • 设计
    • 分发
    • 游戏
    • 配件
    • 网页
    • Home
    • CarPlay 车载
    • 技术

    探索“技术”

    • 概览
    • Xcode
    • Swift
    • SwiftUI

    精选

    • 辅助功能
    • AI 与机器学习
    • App Intents
    • Apple 智能
    • 游戏
    • 安全性
    • Xcode Cloud
    • 社区

    探索“社区”

    • 概览
    • “与 Apple 会面交流”活动
    • 社区活动
    • 开发者论坛
    • 开源

    精选

    • WWDC
    • Swift Student Challenge
    • 开发者故事
    • App Store 大奖
    • Apple 设计大奖
    • Apple Developer Centers
    • 文档

    探索“文档”

    • 文档库
    • 技术概述
    • 示例代码
    • 《人机界面指南》
    • 视频

    发布说明

    • 精选更新
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • Apple tvOS
    • Xcode
    • 下载

    探索“下载”

    • 所有下载
    • 操作系统
    • 应用程序
    • 设计资源

    精选

    • Xcode
    • TestFlight
    • 字体
    • SF Symbols
    • Icon Composer
    • 支持

    探索“支持”

    • 概览
    • 帮助指南
    • 开发者论坛
    • “反馈助理”
    • 联系我们

    精选

    • 《开发者账户帮助》
    • 《App 审核指南》
    • 《App Store Connect 帮助》
    • 即将实行的要求
    • 协议和准则
    • 系统状态
  • 快速链接

    • 活动
    • 新闻
    • 论坛
    • 示例代码
    • 视频
 

视频

打开菜单 关闭菜单
  • 专题
  • 所有视频
  • 关于

更多视频

  • 简介
  • 概要
  • 代码
  • 为 iPhone Duo 构建出色的相机体验

    了解如何充分利用 iPhone Duo 的内外摄像头。探索 Virtual Front Camera,了解如何使用 Direction Coordinator 在摄像头之间切换,并在用户开合 iPhone Duo 时更新 UI。你还能学习处理预览宽高比、定位和旋转的最佳实践,以提供无缝的拍摄体验。

    章节

    • 0:00 - Introduction
    • 0:31 - Meet the new front cameras
    • 0:58 - Discover the virtual front camera
    • 1:53 - Access each camera individually
    • 2:46 - Track camera direction
    • 4:03 - Create a direction coordinator
    • 4:50 - Use both displays at once
    • 5:38 - Work with device descriptors
    • 6:17 - Handle a direction change
    • 7:03 - Polish your camera preview
    • 8:03 - Handle rotation
    • 8:47 - Next steps

    资源

    • Tailor Your Apps for Apple GPUs and Tile-Based Deferred Rendering
    • Metal Feature Set Tables
    • Metal
    • Metal Shading Language Specification
      • 高清视频
      • 标清视频

    相关视频

    Tech Talks

    • 充分利用 iPhone Duo 上的多显示屏和场景

    WWDC26

    • 让你的 iOS App 支持 Center Stage 前置摄像头
  • 搜索此视频…
    • 3:00 - Understand AVCaptureDevicePosition

      enum AVCaptureDevicePosition: Int {
          case unspecified
          case back
          case front
      }
      
      extension AVCaptureDevice {
          // ...
          var position: AVCaptureDevicePosition { get }
      }
    • 4:06 - Initialize a direction coordinator

      directionCoordinator = AVCaptureDeviceDirectionCoordinator(
          view: view,
          deviceTypes: [
              .builtInOuterUltraWideCamera,
              .builtInInnerUltraWideCamera,
              .builtInDualWideCamera,
          ],
          changeHandler: { [weak self] map in
              self?.updateCameraSession(map)
          }
      )
    • 7:30 - Configure the video preview layer

      class AVCaptureVideoPreviewLayer {
          // ...
      
          var videoGravity: AVLayerVideoGravity { get set }
      }
    • 7:51 - Select a dynamic aspect ratio

      class AVCaptureDevice {
          // ...
      
          var dynamicAspectRatio: AVCaptureDevice.AspectRatio? { get }
      }
    • 8:34 - Disable sensor orientation compensation

      // Disable for improved performance
      class AVCapturePhotoOutput: AVCaptureOutput {
          // ...
      
          var isCameraSensorOrientationCompensationEnabled: Bool { get set }
      }
    • 0:00 - Introduction
    • Tarun from the camera software team introduces the new camera features on iPhone Duo: the new front cameras, handling camera direction changes when people open or close the device, and tips for polishing your app's camera preview.

    • 0:31 - Meet the new front cameras
    • iPhone Duo is the first iPhone with two front cameras, both square sensors with an ultrawide field of view. The outer ultrawide camera sits on the outside of the device, while opening it reveals the inner ultrawide camera — the first under-display camera on iPhone.

    • 0:58 - Discover the virtual front camera
    • Stream from the front cameras through AVFoundation, using AVCaptureDeviceDiscoverySession with position .front and the wide or ultrawide device type. On iPhone Duo this discovers the new virtual front camera, which automatically switches between the inner physical camera when open and the outer one when closed, always using the most relevant camera for your app.

    • 1:53 - Access each camera individually
    • Each front camera has its own AVCaptureDevice type — built-in outer ultrawide and built-in inner ultrawide — giving access to each camera's full capabilities. The inner camera supports 1080p up to 60fps, the outer up to 4K and 120fps. The virtual front camera exposes only features common to both, meaning 1080p and 60fps, and depth is supported only when accessing the individual cameras.

    • 2:46 - Track camera direction
    • When using individual cameras, your app is responsible for switching as people open or close the device — use the new AVCaptureDeviceDirectionCoordinator. AVCaptureDevice's position property has always been back or front, and both front cameras report front, but on iPhone Duo the displays can face opposite directions, so a front camera isn't always looking at you. The coordinator keeps your app up to date on where cameras are facing.

    • 4:03 - Create a direction coordinator
    • A direction coordinator needs three things: your app's UIView, the device types to monitor, and a change handler. When your view is on the outer display, outer front cameras report as forward-facing and rear cameras as backward-facing. Opening the device moves your view to the inner display and calls your change handler, which then reports the inner front camera as forward-facing.

    • 4:50 - Use both displays at once
    • A camera app can use both displays simultaneously — useful for a group video call, or for showing a child something fun while photographing them. With a separate UIView per display, create a separate direction coordinator for each, since each reports positions relative to its own view. Camera apps enable this with the SceneAccessories API, covered in "Leverage multiple displays and scenes on iPhone Duo".

    • 5:38 - Work with device descriptors
    • Because the direction coordinator is tied to a view, it's isolated to the main actor, so your change handler shouldn't use AVFoundation APIs directly. Instead of an AVCaptureDevice, the coordinator provides an AVCaptureDeviceDescriptor — a main-actor-safe, sendable representation containing everything needed to create an AVCaptureDevice, which you can safely pass to your camera actor.

    • 6:17 - Handle a direction change
    • When your change handler is called, reconfigure your AVCaptureSession to keep streaming from the forward-facing camera. Consider how the new direction affects mirroring — mirror the preview when the rear camera is forward-facing for a natural selfie experience — and perform any UI updates your app needs. The direction coordinator is found in AVKit.

    • 7:03 - Polish your camera preview
    • Streaming the rear camera's full field of view on the inner display leaves extra space around the preview: offset the preview to group controls in the remaining space, or let it fill the display. Use videoGravity on AVCaptureVideoPreviewLayer to control layout within the layer bounds. When streaming from the ultrawide front cameras, use dynamicAspectRatio on AVCaptureDevice to select a landscape aspect ratio and fill the display.

    • 8:03 - Handle rotation
    • Adopt AVCaptureDeviceRotationCoordinator to keep your camera preview and photos upright. On iPhone Duo it updates when your app moves between displays, so rotation is applied consistently. After adopting it, disable camera sensor orientation compensation — enabled on all iPhone Duo front cameras — to improve performance.

    • 8:47 - Next steps
    • Use the iOS 27.1 SDK to take full advantage of iPhone Duo, decide how your app will handle switching cameras when the device opens or closes, adopt a direction coordinator if you want to move beyond the virtual front camera, and test that your camera preview looks great.

开发者页脚

  • 视频
  • Tech Talks
  • 为 iPhone Duo 构建出色的相机体验
  • 打开菜单 关闭菜单
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    • App Store
    打开菜单 关闭菜单
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    打开菜单 关闭菜单
    • 辅助功能
    • 配件
    • AI 与机器学习
    • Apple 智能
    • 音频与视频
    • 增强现实
    • 商务
    • 设计
    • 分发
    • 教育
    • 游戏
    • 健康与健身
    • App 内购买项目
    • 本地化
    • 地图与位置
    • 安全性
    • Safari 浏览器与网页
    打开菜单 关闭菜单
    • 文档
    • 下载
    • 示例代码
    • 视频
    • 文档归档
    打开菜单 关闭菜单
    • 帮助指南与文章
    • 联系我们
    • 论坛
    • 反馈与错误报告
    • 系统状态
    打开菜单 关闭菜单
    • Apple 开发者
    • App Store Connect
    • 证书、标识符和描述文件
    • “反馈助理”
    打开菜单 关闭菜单
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • 安全赏金计划
    • Security Research Device Program
    打开菜单 关闭菜单
    • 与 Apple 会面交流
    • Apple Developer Center
    • App Store 大奖
    • Apple 设计大奖
    • Apple Developer Academy
    • WWDC
    阅读最近新闻。
    获取 Apple Developer App,并在 bilibili 和微信上关注我们。
    版权所有 © 2026 Apple Inc. 保留所有权利。
    使用条款 隐私政策 协议和准则