我有一个UIImagePicker控制器,有一个按钮叠加,可以翻转相机,拍照等,我希望其中一个可以访问相机胶卷。按下按钮时,我希望相机胶卷打开,当用户选择照片时,它应该开始didFinishPickingMediaWithInfo
。我有这个:
UIImage *cameraRoll = [UIImage imageNamed:@"cameraroll_icon"];
UIButton *cameraRollButton = [UIButton buttonWithType:UIButtonTypeCustom];
cameraRollButton.frame = CGRectMake(250, 0, 48, 30);
[cameraRollButton setImage:cameraRoll forState:UIControlStateNormal];
[cameraRollButton addTarget:self action:@selector(accessCameraRoll:) forControlEvents:UIControlEventTouchUpInside];
[overlay addSubview:cameraRollButton];
// accessCameraRoll
-(IBAction)accessCameraRoll:(id)sender {
// What do I put here to get camera roll for self.imagePicker?
}
答案 0 :(得分:0)
请尝试以下操作,让我们知道会发生什么:)
-(IBAction)accessCameraRoll:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = @[(NSString *) kUTTypeImage];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker
animated:YES completion:nil];
}
}