我想簡單地啓用從UIImagePickerController
中選擇photolibrary中的多個圖像。我是XCode
的新手,我不明白如何讓用戶從多個圖像中選擇多個圖像UIImagePickerControler
。這是我目前的代碼。請幫助任何機構如何從UIImagePickerController
中挑選多個圖像。如何在ios中從UIImagePickerController中選擇多個圖像
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch(buttonIndex)
{
case 0:
[self takeNewPhotoFromCamera];
break;
case 1:
[self choosePhotoFromExistingImages];
default:
break;
}
}
- (void)takeNewPhotoFromCamera
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
controller.allowsEditing = NO;
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
controller.delegate = self;
[self.navigationController presentViewController: controller animated: YES completion: nil];
}
}
-(void)choosePhotoFromExistingImages
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
controller.allowsEditing = NO;
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypePhotoLibrary];
controller.delegate = self;
[self.navigationController presentViewController: controller animated: YES completion: nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self.navigationController dismissViewControllerAnimated: YES completion: nil];
UIImage *image = [info valueForKey: UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation(image, 0.1);
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
{
[self.navigationController dismissViewControllerAnimated: YES completion: nil];
}
Picker無法做到這一點。你需要使用自定義 –
如果你只是看看谷歌的「uiimagepickercontroller多圖像選擇」,你會得到很多可能的解決方案。 –
試試這個代碼http://stackoverflow.com/questions/9542487/select-multiple-images-from-photo-library這可能會幫助你。 –