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;
@endMethod 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
| Parameter | Type | Required | Description |
|---|---|---|---|
current | NSString * | No | The URL of the currently displayed image. It will be displayed first when the preview opens. |
urls | NSArray<NSString *> * | Yes | The list of image URLs to preview; the user can swipe left/right to browse the images in the list. |
Method Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
stateHandle | id<SUDOPStateHandle> | Yes | The state handle object, used to manage the current operation state and callbacks. |
options | SUDOPPreviewImageOptions * | Yes | The 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
- The business side prepares the list of image URLs to preview.
- Create a
SUDOPPreviewImageOptionsobject. - Set
options.urlsto the array of image URLs. - Set
options.currentas needed to the image URL to display first when the preview opens. - Call
previewImage:options:to initiate the image preview operation. - The SDK opens the full-screen image preview page.
- The user can browse the images with gestures such as swiping left/right.
Notes
stateHandleshould not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.optionsshould not be empty.urlsshould not be empty and should contain at least one valid image URL.currentshould generally be one of the items inurls; if it is not set or not inurls, the SDK may display the first image inurlsby default.- The image addresses in
urlscan 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.
