我想簡單地使使用的UIImagePickerController從photolibrary挑選多張圖像,我希望我可以在照片選擇器的底部添加一個子視圖所以它看起來像這樣的應用功能:的UIImagePickerController選擇多個圖片
它有一個簡單的方法你可以做到這一點?我的代碼目前只是以標準方式彈出圖像,但我只在加載時關閉控制器6圖像
重要的是,如果有的話,我可以添加一個小視圖/工具欄到照片選擇器視圖,沒有,然後我可以做其他
- (void)getMediaFromSource:(UIImagePickerControllerSourceType)sourceType{
//get all available source types
NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
//if source type available and supported media type is not null
if ([UIImagePickerController isSourceTypeAvailable:sourceType
&& [mediaTypes count] > 0]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
//picker.mediaTypes = mediaTypes; //allow videos
picker.delegate = self;
picker.sourceType = sourceType; //set source type to the given type
/** WANT TO ADD A CUSTOM VIEW IN THE PHOTO PICKER VIEW **/
[self presentViewController:picker animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing media"
message:@"Device doesn't support that media type"
delegate:nil
cancelButtonTitle:@"Drat !"
otherButtonTitles: nil];
[alert show];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
self.lastChosenMediaType = [info objectForKey:UIImagePickerControllerMediaType]; //record media type
//if media type is image
if ([lastChosenMediaType isEqual:(NSString *) kUTTypeImage]) {
UIImage *chosenImage = [info objectForKey:UIImagePickerControllerOriginalImage]; //load image
//save the image if is from camera shot
if (imageOrVideoSourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum (chosenImage, nil, nil , nil);
}
[images addObject:chosenImage]; //add to image list
imageNum++;
}
changeImageOrVideo = true;
if(imageNum >= 5){
[picker dismissViewControllerAnimated:YES completion:nil];
}
}
查看資產庫。 http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html – iDev
你會有點更詳細?我在看圖書館,但我想我需要一些提示(以前從未使用過) – phil88530
關於資產庫的一些教程是http://www.icodeblog.com/2010/07/08/asset-libraries-and -blocks-in-ios-4 /或http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/你也可以查看這個習慣uiimagepicker實現http://www.icodeblog.com/2011/03/03/update-elcimagepickercontroller/ – iDev