Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 相机预览黑色_Ios_Objective C_Iphone_Camera - Fatal编程技术网

Ios 相机预览黑色

Ios 相机预览黑色,ios,objective-c,iphone,camera,Ios,Objective C,Iphone,Camera,我正在用相机拍照。他们给我看了一张未渲染的快照,结果是一张空快照。确保您的视图在快照之前或屏幕更新之后至少呈现一次 -(IBAction)choosePicture:(id)sender { UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init]; imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

我正在用相机拍照。他们给我看了一张未渲染的快照,结果是一张空快照。确保您的视图在快照之前或屏幕更新之后至少呈现一次

-(IBAction)choosePicture:(id)sender
{
    UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
    imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.delegate=self;
    [self presentViewController:imagePicker animated:YES completion:nil];


}
-(IBAction)takePicture:(id)sender
{
    UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
    imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
    imagePicker.delegate = self;

    [self presentViewController:imagePicker animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
  //  UIImage *pickedImage=[info objectForKey:UIImagePickerControllerOriginalImage];

    image.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    picker.modalPresentationStyle = UIModalPresentationFullScreen;


    [picker dismissViewControllerAnimated:YES completion:nil];

}

在一个空的应用程序中尝试了你的代码,没有消息,一切正常

除了从苹果下载的例子

它也有同样的问题,但一切正常。可能只是个虫子。(如果他们自己的代码具有相同的消息)

如果您有此消息,但有些问题无法正常工作,请尝试类似的问题。例如:

这对我很有效:

-(IBAction)takePicture:(id)sender
{
    UIImagePickerController *imagePickController=[[UIImagePickerController alloc]init];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
       imagePickController.sourceType = UIImagePickerControllerSourceTypeCamera;
    }
    else
    {
       imagePickController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }
    imagePickController.delegate = self;
    imagePickController.allowsEditing = TRUE;
    [self presentViewController:imagePickController animated:YES completion:nil];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
  [self dismissViewControllerAnimated:YES completion:nil];
  <your image> = [info objectForKey:UIImagePickerControllerEditedImage];
}
-(iAction)拍照:(id)发送者
{
UIImagePickerController*ImagePickerController=[[UIImagePickerController alloc]init];
如果([UIImagePickerController IsSourceType可用:UIImagePickerController SourceType相机])
{
ImagePickerController.sourceType=UIImagePickerControllerSourceTypeCamera;
}
其他的
{
ImagePickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
}
imagePickController.delegate=self;
imagePickController.allowsEditing=TRUE;
[self-presentViewController:imagePickController动画:是完成:无];
}
-(void)imagePickerController:(UIImagePickerController*)picker未使用信息完成PickingMediaWithInfo:(NSDictionary*)信息
{
[自我解除视图控制器激活:是完成:无];
=[info objectForKey:UIImagePickerControllerEditedImage];
}