2

I am making an app for the iPad and want to be able to use the iPad 2 camera if available. Is the code to load the iPad camera the same as for the iPhone 4? I have this same code working on the iPhone version of this app, but do not have an iPad 2 to test with and simulator can't help me with the camera. Below is what I have to determine if camera is available and then to load camera or load library in popup

Basically I just need to know if the line below is supported by the iPad 2 camera or do I need to use something else?

[self presentModalViewController:imagePickerController animated:YES];

I want camera to be full screen and not in a popup.

- (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];
    }
}
Brandon
  • 21
  • 2

1 Answers1

0

Yes this works, for sure if self is a UINavigationController. I know this because I do the same in my app. I'm not sure for other UIViewControllers, but it stands to reason that it will also work.

ageektrapped
  • 14,482
  • 7
  • 57
  • 72