chooseImage
Overview
chooseImage:options: opens the image picker to select images from the system album or camera.
The caller can use SUDOPChooseImageOptions to configure the number of images that can be selected, the image size type, and the image source. Based on the passed configuration, the SDK launches the album or camera, and returns the result via callback after selection is complete.
Constant Declaration
objectivec
static NSString * const kSUDOPImageSourceTypeAlbum = @"album";
static NSString * const kSUDOPImageSourceTypeCamera = @"camera";
static NSString * const kSUDOPImageSizeTypeOriginal = @"original";
static NSString * const kSUDOPImageSizeTypeCompressed = @"compressed";Type Declaration
objectivec
/**
Options for configuring image selection behavior.
*/
@interface SUDOPChooseImageOptions : NSObject
/**
The maximum number of images that can be selected.
@default 9
*/
@property(nonatomic, assign) NSInteger count;
/**
The size types of images to be selected.
Possible values: 'original' (original size), 'compressed' (compressed size)
*/
@property(nonatomic, strong) NSArray<NSString *> *sizeType;
/**
The sources for selecting images.
Possible values: 'album' (photo library), 'camera' (camera)
*/
@property(nonatomic, strong) NSArray<NSString *> *sourceType;
@endMethod Declaration
objectivec
/**
Opens the image picker for selecting images from album or camera.
@param stateHandle The state handle object that manages the operation state and callbacks.
@param options The options configuration for image selection (count, sizeType, sourceType, etc.).
*/
- (void)chooseImage:(id<SUDOPStateHandle>)stateHandle
options:(SUDOPChooseImageOptions *)options;Parameters
SUDOPChooseImageOptions
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
count | NSInteger | No | 9 | The maximum number of images that can be selected. |
sizeType | NSArray<NSString *> * | No | - | Image size type. Possible values: original (original image), compressed (compressed image). |
sourceType | NSArray<NSString *> * | No | - | Image source. Possible values: album (album), camera (camera). |
sizeType Values
| Constant | Value | Description |
|---|---|---|
kSUDOPImageSizeTypeOriginal | original | Original image. |
kSUDOPImageSizeTypeCompressed | compressed | Compressed image. |
sourceType Values
| Constant | Value | Description |
|---|---|---|
kSUDOPImageSourceTypeAlbum | album | Select images from the system album. |
kSUDOPImageSourceTypeCamera | camera | Capture images with the camera. |
Method Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
stateHandle | id<SUDOPStateHandle> | Yes | The state handle object, used to manage the current operation state and callbacks. |
options | SUDOPChooseImageOptions * | Yes | The image selection configuration object, containing the selection count, image size type, image source, and other settings. |
Example
objectivec
id<SUDOPStateHandle> stateHandle = self.stateHandle;
SUDOPChooseImageOptions *options = [[SUDOPChooseImageOptions alloc] init];
options.count = 9;
options.sizeType = @[kSUDOPImageSizeTypeOriginal, kSUDOPImageSizeTypeCompressed];
options.sourceType = @[kSUDOPImageSourceTypeAlbum, kSUDOPImageSourceTypeCamera];
[self chooseImage:stateHandle options:options];Process Flow
- The business side creates a
SUDOPChooseImageOptionsobject. - Set the maximum selection count
countaccording to business needs. - Set the image size type
sizeTypeaccording to business needs. - Set the image source
sourceTypeaccording to business needs. - Call
chooseImage:options:to initiate the image selection operation. - The SDK launches the system album or camera based on the configuration.
- After the user selects or captures images, the SDK returns the selection result via callback or state callback.
Notes
stateHandleshould not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.optionsshould not be empty.countindicates the maximum number of images that can be selected; when not set, the default value is9.- When
sourceTypeincludescamera, ensure the App already has camera permission before calling, and configure the camera permission description inInfo.plist. - When
sourceTypeincludesalbum, ensure the App already has album access permission before calling, and configure the album permission description inInfo.plist. - If both album and camera are supported, the SDK or system may first display a source selection entry.
- If only the camera is supported, usually only one image can be captured or selected; the actual behavior depends on the SDK implementation and system capabilities.
- If
sizeTypeincludes bothoriginalandcompressed, the SDK may return images of the corresponding size based on user selection or default policy. - This method has no synchronous return value; the image selection result should be based on the SDK callback or state callback.
