loadView
TypeScriptloadView(): Promise<void>Swift declaration@MainActor override dynamic func loadView()Creates the view that the controller manages.
class · iOS 16.0+ · SDK 27.1
@MainActor @objc class DataScannerViewControllerAn object that scans the camera live video for text, data in text, and machine-readable codes. Use a `DataScannerViewController` object to get input from physical objects that appear in the camera’s live video, such as printed text and QR codes on packages. Create a data scanner by passing parameters that configure the interface to the ``DataScannerViewController/init(recognizedDataTypes:qualityLevel:recognizesMultipleItems:isHighFrameRateTrackingEnabled:isPinchToZoomEnabled:isGuidanceEnabled:isHighlightingEnabled:)`` initializer. Then set its delegate to an object in your app that implements the ``DataScannerViewControllerDelegate`` protocol. Before presenting the view controller, check whether the data scanner is available using the ``DataScannerViewController/isSupported`` and ``DataScannerViewController/isAvailable`` properties. Before you can use the data scanner, you must provide a reason for using the camera (add the <doc://com.apple.documentation/documentation/bundleresources/information_property_list/nscamerausagedescription> key to the information property list), and a person must agree when the system dialog first appears. Then begin data scanning by invoking the ``DataScannerViewController/startScanning()`` method and implement the ``DataScannerViewControllerDelegate/dataScanner(_:didTapOn:)-4z7ql`` and similar delegate methods to handle user actions. Use the ``RecognizedItem`` parameter passed to these methods to perform data-specific actions. For example, if the item is a QR code, perform an action with its payload string, such as opening a URL in a browser, or calling a phone number. Alternatively, you can track items that appear in the live video using the asynchronous ``DataScannerViewController/recognizedItems`` array.
loadView(): Promise<void>Swift declaration@MainActor override dynamic func loadView()Creates the view that the controller manages.
removeFromParent(): Promise<void>Swift declaration@MainActor override dynamic func removeFromParent()viewDidDisappear(animated: boolean): Promise<void>Swift declaration@MainActor override dynamic func viewDidDisappear(_ animated: Bool)Performs some action after the view disappears. - Parameter animated: A Boolean value that indicates whether the view disappears using an animation.
viewDidLoad(): Promise<void>Swift declaration@MainActor override dynamic func viewDidLoad()Performs some action after the system loads the view into memory.
viewWillAppear(animated: boolean): Promise<void>Swift declaration@MainActor override dynamic func viewWillAppear(_ animated: Bool)Performs some action before the view appears. - Parameter animated: A Boolean value that indicates whether the view will appear using an animation.
static init(recognizedDataTypes: Array<DataScannerViewController_RecognizedDataType>, qualityLevel?: DataScannerViewController_QualityLevel, recognizesMultipleItems?: boolean, isHighFrameRateTrackingEnabled?: boolean, isPinchToZoomEnabled?: boolean, isGuidanceEnabled?: boolean, isHighlightingEnabled?: boolean): Promise<DataScannerViewController>Swift declaration@MainActor init(recognizedDataTypes: Set<DataScannerViewController.RecognizedDataType>, qualityLevel: DataScannerViewController.QualityLevel = .balanced, recognizesMultipleItems: Bool = false, isHighFrameRateTrackingEnabled: Bool = true, isPinchToZoomEnabled: Bool = true, isGuidanceEnabled: Bool = true, isHighlightingEnabled: Bool = false)Creates a scanner for finding data, such as text and machine-readable codes, in the camera’s live video. - Parameter recognizedDataTypes: The types of data that the data scanner identifies in the live video. - Parameter qualityLevel: The level of resolution to scan that depends on the size of the items. - Parameter recognizesMultipleItems: A Boolean value that indicates whether the scanner identifies all items in the live video. - Parameter isHighFrameRateTrackingEnabled: A Boolean value that determines the frequency that the scanner updates the geometry of recognized items. - Parameter isPinchToZoomEnabled: A Boolean value that indicates whether people can use a two-finger pinch-to-zoom gesture. - Parameter isGuidanceEnabled: A Boolean value that indicates whether the scanner provides help to a person when selecting items. - Parameter isHighlightingEnabled: A Boolean value that indicates whether the scanner displays highlights around recognized items.
get recognizedDataTypes(): Promise<Array<DataScannerViewController_RecognizedDataType>>Swift declaration@MainActor final let recognizedDataTypes: Set<DataScannerViewController.RecognizedDataType>The types of data that the data scanner identifies in the live video.
get overlayContainerView(): Promise<_UIKit_UIView>Swift declaration@MainActor var overlayContainerView: UIView { get }A view that the data scanner displays over its view without interfering with the Live Text interface. Optionally, add custom highlights to this view that doesn’t interfere with hit-testing or the guidance objects. If you want to add interface objects above the highlights, add those objects as subviews of the <doc://com.apple.documentation/documentation/uikit/uiviewcontroller/1621460-view> property.
get isScanning(): Promise<boolean>Swift declaration@MainActor var isScanning: Bool { get }A Boolean value that indicates whether the data scanner is actively looking for items.
get zoomFactor(): Promise<number>Swift declaration@MainActor var zoomFactor: Double { get set }The zoom factor for the live video in the camera. Set this property to a value between the ``DataScannerViewController/minZoomFactor`` and ``DataScannerViewController/maxZoomFactor`` properties.
setZoomFactor(value: number): Promise<void>Swift declaration@MainActor var zoomFactor: Double { get set }The zoom factor for the live video in the camera. Set this property to a value between the ``DataScannerViewController/minZoomFactor`` and ``DataScannerViewController/maxZoomFactor`` properties.
static get isAvailable(): Promise<boolean>Swift declaration@MainActor class var isAvailable: Bool { get }A Boolean value that indicates whether a person grants your app access to the camera and doesn’t have any restrictions to using the camera. For example, this property may be `false` if a person has Screen Time restrictions.
static get isSupported(): Promise<boolean>Swift declaration@MainActor class var isSupported: Bool { get }A Boolean value that indicates whether the device supports data scanning. For this property to be `true`, the device must have the A12 Bionic chip or later. This property is `false` for apps running in visionOS. - Important: If your app requires data scanning for its core functionality, you can make your app available only on devices that support data scanning. Add the <doc://com.apple.documentation/documentation/bundleresources/information_property_list/uirequireddevicecapabilities> key to your app’s information property list and include the `iphone-ipad-minimum-performance-a12` subkey in the array of device capabilities.
capturePhoto(): Promise<_UIKit_UIImage>Swift declaration@MainActor func capturePhoto() async throws -> UIImageCaptures a high-resolution photo of the camera’s live video. - Returns: An image of the live video.
get qualityLevel(): Promise<DataScannerViewController_QualityLevel>Swift declaration@MainActor final let qualityLevel: DataScannerViewController.QualityLevelThe resolution that the scanner uses to find data. The default value is ``DataScannerViewController/QualityLevel-swift.enum/balanced``. To increase recognition speed for larger items, you can set this property to ``DataScannerViewController/QualityLevel-swift.enum/fast``. For smaller items, you can set this property to ``DataScannerViewController/QualityLevel-swift.enum/accurate`` but it may impact the recognition speed.
stopScanning(): Promise<void>Swift declaration@MainActor func stopScanning()Stops scanning the camera’s live video for data. This method removes all items from the ``DataScannerViewController/recognizedItems`` property.
get maxZoomFactor(): Promise<number>Swift declaration@MainActor var maxZoomFactor: Double { get }The maximum zoom factor that the camera supports.
get minZoomFactor(): Promise<number>Swift declaration@MainActor var minZoomFactor: Double { get }The minimum zoom factor that the camera supports.
startScanning(): Promise<void>Swift declaration@MainActor func startScanning() throwsStarts scanning the camera’s live video for data.
get recognizedItems(): Promise<SDKSequence<Array<RecognizedItem>>>Swift declaration@MainActor var recognizedItems: AsyncStream<[RecognizedItem]> { get }An asynchronous array of items that the data scanner currently recognizes in the camera’s live video. You can use this property instead of the ``DataScannerViewControllerDelegate`` protocol methods to track the recognized items in real time. To get the changes between arrays, use the <doc://com.apple.documentation/documentation/swift/array/difference(from:)> method. For more information on asynchronous streams, see <doc://com.apple.documentation/documentation/swift/concurrency>. Text items in this array appear in the reading order of the language and region.
get regionOfInterest(): Promise<({ x: number; y: number; width: number; height: number }) | null>Swift declaration@MainActor var regionOfInterest: CGRect? { get set }The area of the live video in view coordinates that the data scanner searches for items. If you add interface objects to the live video (using the ``DataScannerViewController/overlayContainerView`` property) that might hide items from a person, set this property to restrict the scanning area. The default value is the bounds of the view.
setRegionOfInterest(value?: ({ x: number; y: number; width: number; height: number }) | null): Promise<void>Swift declaration@MainActor var regionOfInterest: CGRect? { get set }The area of the live video in view coordinates that the data scanner searches for items. If you add interface objects to the live video (using the ``DataScannerViewController/overlayContainerView`` property) that might hide items from a person, set this property to restrict the scanning area. The default value is the bounds of the view.
get isGuidanceEnabled(): Promise<boolean>Swift declaration@MainActor final let isGuidanceEnabled: BoolA Boolean value that indicates whether the scanner provides help to a person when selecting items. The guidance text, such as “Slow Down,” appears over the live video. The default value for this property is `true`.
get isPinchToZoomEnabled(): Promise<boolean>Swift declaration@MainActor final let isPinchToZoomEnabled: BoolA Boolean value that indicates whether people can use a two-finger pinch-to-zoom gesture. The default value is `true`.
get isHighlightingEnabled(): Promise<boolean>Swift declaration@MainActor final let isHighlightingEnabled: BoolA Boolean value that indicates whether the scanner displays highlights around recognized items. The default value is `false`.
get recognizesMultipleItems(): Promise<boolean>Swift declaration@MainActor final let recognizesMultipleItems: BoolA Boolean value that indicates whether the scanner should identify all items in the live video. If `true`, the scanner finds all items in the live video. If `false`, the scanner finds only the item closest to a person’s point of interest. The point of interest is the middle of the view by default or where a person taps in the live video. The default value is `false`.
get isHighFrameRateTrackingEnabled(): Promise<boolean>Swift declaration@MainActor final let isHighFrameRateTrackingEnabled: BoolA Boolean value that determines the frequency at which the scanner updates the geometry of recognized items. If `true`, the scanner updates the geometry of items more frequently allowing your app to closely track recognized items. If you don’t track items in the live video, set this property to `false`. The default value is `true`.
static get supportedTextRecognitionLanguages(): Promise<Array<string>>Swift declaration@MainActor class var supportedTextRecognitionLanguages: [String] { get }The identifiers for the languages that the data scanner recognizes.
get delegate(): Promise<(SDKHandle) | null>Swift declaration@MainActor weak var delegate: (any DataScannerViewControllerDelegate)?The delegate that handles user interaction with items recognized by the data scanner.
setDelegate(value?: (SDKHandle) | null): Promise<void>Swift declaration@MainActor weak var delegate: (any DataScannerViewControllerDelegate)?The delegate that handles user interaction with items recognized by the data scanner.
No declarations were skipped in this snapshot.