Skip to content

previewImage ​

Overview ​

previewImage:options: previews images in full-screen mode and supports gesture interactions related to image browsing, such as swiping left/right to switch images.

The caller needs to pass the currently displayed image address and the image address list via SUDOPPreviewImageOptions. Based on the configuration, the SDK opens the image preview page and displays the image specified by current first.

Type Declaration ​

objectivec
/**
 Options for configuring image preview behavior.
 */
@interface SUDOPPreviewImageOptions : NSObject

/**
 The URL link of the currently displayed image.
 This image will be shown first when the preview opens.
 */
@property(nonatomic, strong) NSString *current;

/**
 The list of image URL links to be previewed.
 Users can swipe left/right to browse through all images in this list.
 */
@property(nonatomic, strong) NSArray<NSString *> *urls;

@end

Method Declaration ​

objectivec
/**
 Previews an image in full-screen mode with support for gesture interactions.
 @param stateHandle The state handle object that manages the operation state and callbacks.
 @param options The options configuration for image preview (e.g., image URLs, current index, show save button).
 */
- (void)previewImage:(id<SUDOPStateHandle>)stateHandle
             options:(SUDOPPreviewImageOptions *)options;

Parameters ​

SUDOPPreviewImageOptions ​

ParameterTypeRequiredDescription
currentNSString *NoThe URL of the currently displayed image. It will be displayed first when the preview opens.
urlsNSArray<NSString *> *YesThe list of image URLs to preview; the user can swipe left/right to browse the images in the list.

Method Parameters ​

ParameterTypeRequiredDescription
stateHandleid<SUDOPStateHandle>YesThe state handle object, used to manage the current operation state and callbacks.
optionsSUDOPPreviewImageOptions *YesThe image preview configuration object, containing the currently displayed image address and the image address list.

Example ​

objectivec
id<SUDOPStateHandle> stateHandle = self.stateHandle;

SUDOPPreviewImageOptions *options = [[SUDOPPreviewImageOptions alloc] init];
options.current = @"https://example.com/images/1.png";
options.urls = @[
    @"https://example.com/images/1.png",
    @"https://example.com/images/2.png",
    @"https://example.com/images/3.png"
];

[self previewImage:stateHandle options:options];

Process Flow ​

  1. The business side prepares the list of image URLs to preview.
  2. Create a SUDOPPreviewImageOptions object.
  3. Set options.urls to the array of image URLs.
  4. Set options.current as needed to the image URL to display first when the preview opens.
  5. Call previewImage:options: to initiate the image preview operation.
  6. The SDK opens the full-screen image preview page.
  7. The user can browse the images with gestures such as swiping left/right.

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.
  • urls should not be empty and should contain at least one valid image URL.
  • current should generally be one of the items in urls; if it is not set or not in urls, the SDK may display the first image in urls by default.
  • The image addresses in urls can be network image addresses or local image paths supported by the SDK; this depends on the actual implementation.
  • If an image is a network address, the caller should ensure the image URL is accessible.
  • This method has no synchronous return value; the preview state or exception result should be based on the SDK callback or state callback.