如何使它也适用于 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];
}