如何在Simulator环境中使用UIImagePickerController的CameraOverlayView属性

时间:2014-07-27 19:55:53

标签: ios ios-simulator uiimagepickercontroller

我正在创建一个自定义的Camera Overlay并将其设置为UIImagePickerController的CameraOverlayView属性。

但是,由于我没有加入Apple的开发人员计划,因此无法在实际设备上部署和测试应用程序包。

我还调试了我的代码,看起来在Simulator上你无法真正选择 imagePicker.sourceType 属性并将其设置为 UIImagePickerControllerSourceTypeCamera 。因为模拟器上没有相机功能。

我的思考是否正确?
或者我错过了什么,有一种方法可以设置CameraOverlayView属性并在模拟器上测试它?

以下是我的代码示例:

- (IBAction)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];

// Check what is possible or supported on simulator, otherwise,
//just pick from Photo library

if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}

if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
    imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else  {
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}


// Allow edit
[imagePicker  setEditing:YES animated:YES   ];
[imagePicker setAllowsEditing:YES];
imagePicker.delegate = self;

// set custom Overlay
//imagePicker.cameraOverlayView = ( not working in simulator )

//Display the imagePicker on the screen

[self presentViewController:imagePicker animated:YES completion:NULL];
}

1 个答案:

答案 0 :(得分:1)

你是对的,相机在iOS模拟器中不起作用。