我正在为iPad制作应用程序,并希望能够使用iPad 2相机(如果有)。加载iPad相机的代码是否与iPhone 4相同?我有相同的代码工作在这个应用程序的iPhone版本,但没有iPad 2进行测试,模拟器无法帮助我使用相机。下面是我必须确定相机是否可用,然后在弹出窗口中加载相机或加载库
基本上我只需要知道iPad 2相机是否支持以下线路,还是需要使用其他产品?
[self presentModalViewController:imagePickerController animated:YES];
我希望相机全屏,而不是弹出窗口。
- (IBAction) takePhoto:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self presentModalViewController:imagePickerController animated:YES];
} else {
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
imageView.contentMode = UIViewContentModeScaleAspectFit;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
[popover setDelegate:self];
[popover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}
答案 0 :(得分:0)
是的,如果self
是UINavigationController,肯定是。我知道这是因为我在我的应用程序中也这样做。我不确定其他UIViewControllers,但它有理由它也会起作用。