2

我已经从模态呈现的视图控制器中呈现了 UIImagePickerController。单击图像后,我得到一个黑色图像而不是单击的图片,我做了这样的事情。

//From ViewController1 I presented view controller2 with 
- (IBAction)buttontappedToPresentViewController2:(id)sender
{
    ViewController2* controller2 = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil];
    controller2.modalPresentationStyle = UIModalPresentationPageSheet;
    [self controller2 animated:YES completion:nil];
}


//In ViewController2, I presented the UIIMagePickerController
- (IBAction)cameraButtonTapped:(id)sender
{
    UIImagePickerController *cameraController = [[UIImagePickerController alloc] init];
    cameraController.mediaTypes = @[(NSString *)kUTTypeImage,(NSString*)kUTTypeMovie];
    cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentViewController:cameraController animated:YES completion:NULL];
}

单击图像后,您将获得黑屏,而不是重新拍摄的捕获图像并使用照片选项。如果您选择“使用照片”选项,您将在回调中获得正确的图像。

注意:如果您没有为 viewController2 设置 UIModalPresentationStyle,则代码可以正常工作。

知道这里出了什么问题。

编辑:我使用了 XCODE 5.1,我的目标部署是 iOS 7。我在 iOS8 设备上运行该应用程序。

4

0 回答 0