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];
    }
}
4

1 回答 1

0

是的,这可以确定是否self是 UINavigationController。我知道这一点,因为我在我的应用程序中做同样的事情。我不确定其他 UIViewControllers,但它也可以正常工作。

于 2011-06-17T15:17:24.340 回答