How to access iOS simulator camera [duplicate]

2019-03-17 02:33发布

This question already has an answer here:

Hi friends i am doing camera app. i need to test the app in simulator but i can't able to access the iOS simulator camera. Any help for my problem. If not possible in simulator means 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..

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条回答
够拽才男人
2楼-- · 2019-03-17 03:12

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

查看更多
Bombasti
3楼-- · 2019-03-17 03:24

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.

查看更多
登录 后发表回答