我有一个适用于 iPhone 和 iPad 的应用程序,当我尝试为 iPad 加载一个应用程序时,UIPickerViewController
我UIPopoverController
得到了异常“源类型 1 不可用”。即使使用该设备也会出现问题。
@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];
}