これをiPadでも機能させるにはどうすればよいですか?iPhone では正常に動作しますが、Apple はすべてのアプリが iPad で動作することを要求しています。これについて何か助けはありますか?
- (IBAction)chooseImage:(id)sender
{
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
[self.imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:self.imagePicker animated:YES completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
self.image = info[UIImagePickerControllerOriginalImage];
[self.imageView setImage:self.image];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
これでここまできました!iPad を使用してフォト ライブラリから画像を選択しても、クラッシュしなくなりました。問題は、画像が選択されないことですか?
助言がありますか?
- (IBAction)chooseImage:(id)sender
{
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
[self.imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
_popover = [[UIPopoverController alloc] initWithContentViewController:_imagePicker];
_popover.delegate = self;
[_popover setPopoverContentSize:CGSizeMake(320, 460)];
[_popover presentPopoverFromBarButtonItem:[[UIBarButtonItem alloc]initWithCustomView:(UIButton*)sender] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
[self presentViewController:self.imagePicker animated:YES completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if
(self.popover && self.popover.popoverVisible) {
[self.popover dismissPopoverAnimated:YES];
}
else
self.image = info[UIImagePickerControllerOriginalImage];
[self.imageView setImage:self.image];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}