1

我有一个 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?


}
4

1 回答 1

0

please try the following , and let us know what happens :)

-(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];
    }
}
于 2013-10-27T08:56:32.440 回答