2

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

1 に答える 1

0

はい、これは動作します。UINavigationController であるかどうかは確かです。self私は自分のアプリで同じことをしているので、これを知っています。他のUIViewControllersについてはわかりませんが、それも機能するのは当然です。

于 2011-06-17T15:17:24.340 に答える