2

在此处输入图像描述

如何添加按钮并选择照片。请帮助并告诉我如何解决

4

2 回答 2

2

您需要创建一个 CustomOverlayView。然后像这样配置你的选择器:

    overlay = [[CustomOverlayView alloc]initWithFrame:self.view.bounds];
    overlay.delegate = self;
    picker = [[UIImagePickerController alloc]init];
    picker.delegate = self;
    picker.navigationBarHidden = YES;
    picker.toolbarHidden = YES;
    picker.wantsFullScreenLayout = YES;
    picker.allowsEditing = YES;
    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]){

        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }
    else{
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }
    picker.showsCameraControls = NO;
    picker.cameraOverlayView = overlay;
于 2013-05-23T15:39:30.487 回答
-1

这将起作用:

- (void)showImagePicker:(UIImagePickerControllerSourceType)source{
    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
    imgPicker.sourceType = source;



    imgPicker.delegate = self;
    [self presentModalViewController:ipc animated:YES];
}

按钮按下动作:

- (IBAction)chooseImage:(id)sender {

    [self showImagePicker:UIImagePickerControllerSourceTypePhotoLibrary];

}

并这样做:

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    [picker dismissViewControllerAnimated:YES completion:nil];
}

或通过正确的操作执行此代码

于 2013-05-23T15:37:54.853 回答