iOS 개발 사진 다중 선택 기능
addImage.gif
이 기능은 두 개의 타사 라이브러리를 사용했습니다.
https://github.com/iphone5solo/PYPhotoBrowser
https://github.com/banchichen/TZImagePickerController
PYPhotoBrowser
코코푸드를 사용하여 설치하는 방식: pod "PYPhotoBrowser"
그리고 메인 헤더 파일 가져오기#import
TZImagePickerController
코코푸드를 사용하여 설치하는 방식: pod 'TZImagePickerController'
그리고 메인 헤더 파일 가져오기#import "TZImagePickerController.h
만약에 이 두 제3자의 역할을 모르면git주소를 열어 문서에서 받아들인 에이전트를 TZImagePickerControllerDelegate
,PYPhotosViewDelegate
속성을 정의하여 선택한 그림을 저장할 수 있습니다. 선택을 누르면 그림 단추 호출 방법을 추가합니다.-(void)ininPhotoView{
// 1. photosView
PYPhotosView *publishPhotosView = [PYPhotosView photosView];
publishPhotosView.py_x = 5;
publishPhotosView.py_y = 10;
// 2.1
publishPhotosView.images = nil;
// 3.
publishPhotosView.delegate = self;
publishPhotosView.photosMaxCol = 4;//
publishPhotosView.imagesMaxCountWhenWillCompose = 3;//
// 4. photosView
[self.view addSubview:publishPhotosView];
self.publishPhotosView = publishPhotosView;
}
완료해야 하는 에이전트 방법
#pragma mark - PYPhotosViewDelegate
- (void)photosView:(PYPhotosView *)photosView didAddImageClickedWithImages:(NSMutableArray *)images{
// , 。
[self getPhotos];
}
//미리 보기 그림에 들어갈 때 호출하면 미리 보기 컨트롤러를 얻을 수 있으며 내비게이션 표시줄에 대한 사용자 정의를 실현할 수 있습니다
- (void)photosView:(PYPhotosView *)photosView didPreviewImagesWithPreviewControlelr:(PYPhotosPreviewController *)previewControlelr{
NSLog(@" ");
}
앨범에 들어가는 방법:
-(void)getPhotos{
CCDefineWeakSelf;
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:3-weakSelf.photos.count delegate:weakSelf];
// block , .
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray *photos, NSArray *assets,BOOL isSelectOriginalPhoto){
NSLog(@"photos===%@",photos);
for (UIImage *image in photos) {
[weakSelf requestData:image];//requestData:
}
[weakSelf.photos addObjectsFromArray:photos];
[self.publishPhotosView reloadDataWithImages:weakSelf.photos];
}];
[weakSelf presentViewController:imagePickerVc animated:YES completion:nil];
}
@property (nonatomic, weak) PYPhotosView *publishPhotosView;
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.