---
title: ImageAnalysisInteraction
framework: visionkit
role: symbol
role_heading: Class
path: visionkit/imageanalysisinteraction
---

# ImageAnalysisInteraction

An interface that enables people to interact with recognized text, barcodes, and other objects in an image.

## Declaration

```swift
@MainActor @objc final class ImageAnalysisInteraction
```

## Mentioned in

Enabling Live Text interactions with images

## Overview

Overview This class enables people to interact with specific content types (ImageAnalysisInteraction.InteractionTypes) that the framework identifies in an image. For example: The Live Text interface enables them to select any text present in the image (textSelection), or invoke a URL (dataDetectors). The text selection UI offers framework-standard buttons for copying selected text, or looking it up on the web for more information. The subject lift feature identifies a wide variety of objects, or subjects, in images with the imageSubject interaction type, and provides your app with an image of the objects with the background removed. The visualLookUp type supplements this feature by adding a button in the bottom corner of the view that people can click or tap for more information about the recognized subjects. Configure the interface and begin interaction This class conforms to the UIInteraction protocol. To connect the interface with an image that your app displays, call addInteraction(_:) on your app’s image view and pass in a new instance of this class. Choose the items that the framework recognizes in an image by configuring the  preferredInteractionTypes property. To recognize all types of content, specify the automatic option, or choose a combination of types by assigning an array: interaction.preferredInteractionTypes = [.textSelection, .imageSubject] To begin interaction, call one of the ImageAnalyzer class’s analyze methods, such as analyze(_:configuration:) and set the result onto this class’s analysis property. You can take more control over the interaction or provide details about your app’s image view by implementing a delegate (ImageAnalysisInteractionDelegate) and assigning it to the delegate property. If your image view isn’t an instance of UIImageView, your app needs to define the interactive area within the image by implementing the contentsRect(for:) method.

## Topics

### Creating an image interaction

- [init()](visionkit/imageanalysisinteraction/init().md)
- [init(_:)](visionkit/imageanalysisinteraction/init(_:).md)

### Configuring an image interaction

- [delegate](visionkit/imageanalysisinteraction/delegate.md)
- [analysis](visionkit/imageanalysisinteraction/analysis.md)
- [view](visionkit/imageanalysisinteraction/view.md)
- [preferredInteractionTypes](visionkit/imageanalysisinteraction/preferredinteractiontypes.md)
- [ImageAnalysisInteraction.InteractionTypes](visionkit/imageanalysisinteraction/interactiontypes.md)
- [activeInteractionTypes](visionkit/imageanalysisinteraction/activeinteractiontypes.md)

### Responding to view events

- [willMove(to:)](visionkit/imageanalysisinteraction/willmove(to:).md)
- [didMove(to:)](visionkit/imageanalysisinteraction/didmove(to:).md)

### Accessing text information

- [text](visionkit/imageanalysisinteraction/text.md)
- [selectedText](visionkit/imageanalysisinteraction/selectedtext.md)
- [selectedAttributedText](visionkit/imageanalysisinteraction/selectedattributedtext.md)
- [hasText(at:)](visionkit/imageanalysisinteraction/hastext(at:).md)
- [hasActiveTextSelection](visionkit/imageanalysisinteraction/hasactivetextselection.md)
- [analysisHasText(at:)](visionkit/imageanalysisinteraction/analysishastext(at:).md)
- [hasDataDetector(at:)](visionkit/imageanalysisinteraction/hasdatadetector(at:).md)

### Managing text selection

- [selectedRanges](visionkit/imageanalysisinteraction/selectedranges.md)
- [resetTextSelection()](visionkit/imageanalysisinteraction/resettextselection().md)

### Accessing image subjects

- [subjects](visionkit/imageanalysisinteraction/subjects.md)
- [ImageAnalysisInteraction.Subject](visionkit/imageanalysisinteraction/subject.md)
- [image(for:)](visionkit/imageanalysisinteraction/image(for:).md)
- [subject(at:)](visionkit/imageanalysisinteraction/subject(at:).md)

### Managing image subjects

- [highlightedSubjects](visionkit/imageanalysisinteraction/highlightedsubjects.md)

### Querying the interface state

- [liveTextButtonVisible](visionkit/imageanalysisinteraction/livetextbuttonvisible.md)
- [isSupplementaryInterfaceHidden](visionkit/imageanalysisinteraction/issupplementaryinterfacehidden.md)
- [hasInteractiveItem(at:)](visionkit/imageanalysisinteraction/hasinteractiveitem(at:).md)
- [hasSupplementaryInterface(at:)](visionkit/imageanalysisinteraction/hassupplementaryinterface(at:).md)
- [selectableItemsHighlighted](visionkit/imageanalysisinteraction/selectableitemshighlighted.md)

### Customizing the interface

- [allowLongPressForDataDetectorsInTextMode](visionkit/imageanalysisinteraction/allowlongpressfordatadetectorsintextmode.md)
- [setSupplementaryInterfaceHidden(_:animated:)](visionkit/imageanalysisinteraction/setsupplementaryinterfacehidden(_:animated:).md)
- [supplementaryInterfaceContentInsets](visionkit/imageanalysisinteraction/supplementaryinterfacecontentinsets.md)
- [supplementaryInterfaceFont](visionkit/imageanalysisinteraction/supplementaryinterfacefont.md)

### Managing custom image views

- [contentsRect](visionkit/imageanalysisinteraction/contentsrect.md)
- [setContentsRectNeedsUpdate()](visionkit/imageanalysisinteraction/setcontentsrectneedsupdate().md)

### Errors

- [ImageAnalysisInteraction.SubjectUnavailable](visionkit/imageanalysisinteraction/subjectunavailable.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)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UIInteraction](uikit/uiinteraction.md)

## See Also

### Content recognition and interaction in images

- [Enabling Live Text interactions with images](visionkit/enabling-live-text-interactions-with-images.md)
- [ImageAnalyzer](visionkit/imageanalyzer.md)
- [ImageAnalysis](visionkit/imageanalysis.md)
- [ImageAnalysisInteractionDelegate](visionkit/imageanalysisinteractiondelegate.md)
- [ImageAnalysisOverlayView](visionkit/imageanalysisoverlayview.md)
- [ImageAnalysisOverlayViewDelegate](visionkit/imageanalysisoverlayviewdelegate.md)
- [CameraRegionView](visionkit/cameraregionview.md)
