如何访问iOS模拟器相机

R M*_*R M 58 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];    
}
Run Code Online (Sandbox Code Playgroud)

Sal*_*idi 76

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

  • 哇,这太可悲了,苹果。而且这个从2014年以来就没有改变过吗? (97认同)
  • @JCutting8 因为苹果很贪婪,强迫人们购买设备,即使是像相机模拟这样的基本功能,Android 模拟器几年前就已经有了...... (39认同)
  • 苹果的这个想法真的很愚蠢,安卓的模拟器允许我使用我的网络摄像头或者只是提供一个模拟图像,你们就不能想出这个,而是要求我使用真实的设备吗?这表明,对于苹果来说,一切都是为了钱,而不是开发者。 (26认同)
  • 我想知道为什么他们从来没有这样做过?我的意思是,Android Studio 已经做到了,所以利用网络摄像头来模拟设备摄像头似乎绝对是可能的。 (12认同)
  • 我不应该对苹果让开发者的生活变得艰难感到惊讶。但我每次还是措手不及。 (12认同)
  • 直到现在,我仍然不敢相信这一点。干得好,苹果,继续努力..哈哈 (5认同)
  • @MatPag我的意思是,如果他们想这样做,他们根本不会包含模拟器,除非你有另一个阴谋贡献......;) (4认同)
  • 在这上面浪费了一天的pro max plus ultra。感谢您澄清这一点,现在我需要购买一台二手设备。 (2认同)

Che*_*tan 31

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