如何访问iOS模拟器相机

时间:2014-08-25 12:34:39

标签: ios ios-simulator ios-camera

嗨朋友我正在做相机应用程序。我需要在simulator中测试该应用,但我无法访问iOS simulator相机。对我的问题有任何帮助。如果在simulator中无法实现,则意味着我需要访问我的系统相机。是否有可能?我尝试过图像视图控制器,但它不起作用。任何帮助将不胜感激。 以下代码只是我试过..

self.imagePicker = [[UIImagePickerController alloc] init];  
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.usingPopover = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
sourceType = UIImagePickerControllerSourceTypeCamera;
self.usingPopover = NO;
}
[self.imagePicker setSourceType:sourceType];
self.imagePicker.allowsEditing = NO;
self.imagePicker.delegate = self;
if (sourceType != UIImagePickerControllerSourceTypeCamera) {
self.popover = [[UIPopoverController alloc] initWithContentViewController:self.imagePicker];
self.popover.delegate = self;
[self.popover presentPopoverFromRect:popoverFrame inView:self.view  
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[self presentModalViewController:imagePicker animated:YES];    
}

2 个答案:

答案 0 :(得分:66)

无法访问开发机器的相机以用作模拟器相机。任何iOS版本和任何模拟器都不提供相机功能。您只能使用设备来测试相机目的。

答案 1 :(得分:26)

模拟器没有相机。如果要访问摄像头,则需要设备。你不能在模拟器上测试相机。您只能查看照片和视频库。

相关问题