ios 如何访问iOS模拟器相机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25486080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:02:23  来源:igfitidea点击:

How to access iOS simulator camera

iosios-simulatorios-camera

提问by R M

Hi friends i am doing camera app. i need to test the app in simulatorbut i can't able to access the iOS simulatorcamera. Any help for my problem. If not possible in simulatormeans i need to access my system camera. Whether it is possible?I tried Image picture view controller but it not works .Any help will be appreciated. The below code only i tried..

嗨,朋友们,我正在做相机应用程序。我需要测试应用程序,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];    
}

回答by Salman Zaidi

It's not possible to access camera of your development machine to be used as simulator camera. Camera functionality is not available in any iOSversion and any Simulator. You will have to use device for testing camera purpose.

无法访问开发机器的摄像头以用作模拟器摄像头。相机功能在任何iOS版本和任何模拟器中均不可用。您将不得不使用设备来测试相机。

回答by Chetan

Simulator doesn't have a Camera. If you want to access a camera you need a device. You can't test camera on simulator. You can only check the photo and video gallery.

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