UIImagePickerController白屏?

时间:2012-05-03 08:17:43

标签: ios delegates uiimagepickercontroller white-box

早上好。

我遇到的问题是UIImagePickerController没有显示除white之外的任何内容。我的主头文件中有一个320x320 UIImageView:

IBOutlet UIImageView *_cameraView;

同时:

@property (nonatomic, retain) UIImagePickerController *_cameraPicker;
@property (nonatomic, retain) UIImage *_noCam;

_noCam是一个图像,如果用户没有摄像头,则放在视图中。这很好。

我试图在这个方形视图顶部显示(没有标准相机GUI,但现在可以等待)相机。在我的主要课程中,我有:

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"viewDidAppear did appear too");
//camera view etc
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    //code here to not allow picture taking, probably put up something saying you don'thave a camera on your device
    NSLog(@"no cam available");
    _noCam = [UIImage imageNamed:@"noCam.png"];
    [_cameraView setImage:_noCam];
} else {
    //take the shot
    _cameraPicker = [[UIImagePickerController alloc] init];
    _cameraPicker.delegate = _cameraView;
    _cameraPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    NSLog(@"cam is available");
}

}

我猜我在设置委托方面遇到了问题。 _self给我一个错误类型:

'来自不兼容的类型' ViewController * const _strong'

我使用NSLog来检查方法是否有效,它告诉我调用了viewDidLoad和viewDidAppear方法并且检测到了摄像头但是我只是得到了白色视图。

非常感谢任何帮助。

感谢。

1 个答案:

答案 0 :(得分:0)

您需要以某种方式显示选择器,您可以使用默认GUI:

  [self presentModalViewController:_cameraPicker animated:YES];

或查看UIImagePickerControllercameraOverlayView