即使使用设备也能解决问题。
@try { if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.delegate = self; imagePicker.allowsEditing = NO; self.tempComp = component; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { [self presentModalVIEwController:imagePicker animated:YES]; }else { // We are using an iPad popoverController=[[UIPopoverController alloc] initWithContentVIEwController:imagePicker]; popoverController.delegate = self; [popoverController presentPopoverFromrect:component.bounds inVIEw:component permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } }else{ UIAlertVIEw *alert = [[UIAlertVIEw alloc] initWithTitle:@"Camera Non disponibile" message:@"La camera non è disponibile" delegate:self cancelbuttonTitle:@"Ok" otherbuttonTitles: nil]; [alert show]; }}@catch (NSException *exception) { NSLog(@"Cattura eccezione %@",exception); UIAlertVIEw *alert = [[UIAlertVIEw alloc] initWithTitle:@"Eccezione" message:[Nsstring stringWithFormat:@"%@",exception] delegate:self cancelbuttonTitle:@"Ok" otherbuttonTitles: nil]; [alert show];}解决方法 这是因为你在模拟器上打开相机
因为代码就像[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]
显然模拟器没有相机…
继续发出这样的警报,
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIAlertVIEw *myAlertVIEw = [[UIAlertVIEw alloc] initWithTitle:@"Error" message:@"Device has no camera" delegate:nil cancelbuttonTitle:@"OK" otherbuttonTitles: nil]; [myAlertVIEw show];}else{//other action}
没关系,它会正常工作在设备上!
总结以上是内存溢出为你收集整理的ios – 源类型1不可用全部内容,希望文章能够帮你解决ios – 源类型1不可用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)