Skip to content

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;

@end

Method 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 ​

ParameterTypeRequiredDefaultDescription
countNSIntegerNo9The maximum number of images that can be selected.
sizeTypeNSArray<NSString *> *No-Image size type. Possible values: original (original image), compressed (compressed image).
sourceTypeNSArray<NSString *> *No-Image source. Possible values: album (album), camera (camera).

sizeType Values ​

ConstantValueDescription
kSUDOPImageSizeTypeOriginaloriginalOriginal image.
kSUDOPImageSizeTypeCompressedcompressedCompressed image.

sourceType Values ​

ConstantValueDescription
kSUDOPImageSourceTypeAlbumalbumSelect images from the system album.
kSUDOPImageSourceTypeCameracameraCapture images with the camera.

Method Parameters ​

ParameterTypeRequiredDescription
stateHandleid<SUDOPStateHandle>YesThe state handle object, used to manage the current operation state and callbacks.
optionsSUDOPChooseImageOptions *YesThe 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 ​

  1. The business side creates a SUDOPChooseImageOptions object.
  2. Set the maximum selection count count according to business needs.
  3. Set the image size type sizeType according to business needs.
  4. Set the image source sourceType according to business needs.
  5. Call chooseImage:options: to initiate the image selection operation.
  6. The SDK launches the system album or camera based on the configuration.
  7. After the user selects or captures images, the SDK returns the selection result via callback or state callback.

Notes ​

  • stateHandle should not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.
  • options should not be empty.
  • count indicates the maximum number of images that can be selected; when not set, the default value is 9.
  • When sourceType includes camera, ensure the App already has camera permission before calling, and configure the camera permission description in Info.plist.
  • When sourceType includes album, ensure the App already has album access permission before calling, and configure the album permission description in Info.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 sizeType includes both original and compressed, 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.