【问题标题】:Camera not working in landscape mode only project?相机仅在横向模式下无法工作?
【发布时间】:2015-08-07 06:19:51
【问题描述】:

我已经开发了仅横向模式的项目和使用拍照的 UIcamera 图片控制器,但是当相机启动时它崩溃了,它会显示这个原因:对尚未渲染的视图进行快照会导致空快照。确保在快照或屏幕更新后的快照之前至少渲染一次视图。

 if ([UIImagePickerController isSourceTypeAvailable:
         UIImagePickerControllerSourceTypeCamera])
    {
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];
        imagePicker.allowsEditing = NO;


        [self presentModalViewController:imagePicker animated:YES];
//        [self presentViewController:imagePicker animated:NO completion:^{
//                [imagePicker setShowsCameraControls:YES];
//            }];

        }else{
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"No camera available" message: @"Failed to take image" delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }

【问题讨论】:

    标签: objective-c camera landscape


    【解决方案1】:

    试试这个朋友:

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
    
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsEditing = YES;
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    
        [self presentViewController:picker animated:YES completion:NULL];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No camera available" message:@"Failed to take image" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-17
      • 2011-11-26
      相关资源
      最近更新 更多