All Products
Search
Document Center

Image picker encapsulation

Last Updated: May 25, 2021

AUImagePickerSkeleton is an image selection component that encapsulates the vision and interaction functions. It does not support album calling, browsing, or uploading. Currently, the image selection functions are incomplete. The component that inherits functions will be added to BEEViews.

Sample image

Dependency

 
  1. Currently, this component is not added to the AntUI baseline.

API description

 
  1. @protocol AUImagePickerDataProtocol <NSObject>
  2. - (UIImage *)image;
  3. @end
  4. @interface AUImagePickerSkeleton : UIView
  5. - (AUImagePickerSkeleton *)initWithTitle:(NSString *)title
  6. maxNumberOfImages:(NSUInteger)maxNumberOfImages;
  7. @property(nonatomic, assign, readonly) NSUInteger maxNumberOfImages;
  8. @property(nonatomic, weak) id<AUImagePickerDelegate> delegate;
  9. @property(nonatomic, strong, readonly) NSArray<id<AUImagePickerDataProtocol>> *imagePickerDatas;
  10. - (void)updateImagePickerDatas:(NSArray <id<AUImagePickerDataProtocol>>*) datas;
  11. @end
  12. @protocol AUImagePickerDelegate <NSObject>
  13. @required
  14. - (void)imagePickerAddButtonClick:(AUImagePickerSkeleton *)imagePicker;
  15. @optional
  16. - (void)imagePickerImageClick:(AUImagePickerSkeleton *)imagePicker
  17. clickData:(id<AUImagePickerDataProtocol>)clickData;
  18. @end

Sample code

 
  1. - (void)viewDidLoad {
  2. [super viewDidLoad];
  3. self.datas = [[NSMutableArray alloc] init];
  4. self.picker = [[AUImagePickerSkeleton alloc] initWithTitle:@"图片(选填,上传问题截图)" maxNumberOfImages:4];
  5. self.picker.top = 100;
  6. self.picker.delegate = self;
  7. [self.view addSubview:self.picker];
  8. [self.view addSubview:self.button];
  9. self.view.backgroundColor = RGB(0xEBEBEB);
  10. }
  11. - (void)imagePickerAddButtonClick:(AUImagePickerSkeleton *)imagePicker
  12. {
  13. AUImagePickerData *data = [AUImagePickerData new];
  14. data.originalImage = [self getImageWithCount:[self.datas count]];
  15. [self.datas addObject:data];
  16. [self updatePickerAndResize];
  17. }
  18. -(void)imagePickerImageClick:(AUImagePickerSkeleton *)imagePicker
  19. clickData:(id<AUImagePickerDataProtocol>)clickData
  20. {
  21. NSString *msg = @"";
  22. if ([self.datas containsObject:clickData]) {
  23. msg = [NSString stringWithFormat:@"Tap image %d",(int)[self.datas indexOfObject:clickData]+1];
  24. }else{
  25. msg = @"The image tapped is abnormal";
  26. }
  27. [AUToast presentModalToastWithin:self.view
  28. withIcon:AUToastIconNone
  29. text:msg
  30. duration:1
  31. logTag:@"demo"
  32. completion:NULL];
  33. }