Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 这对iPad也适用吗?_Iphone_Image_Ipad_Load - Fatal编程技术网

Iphone 这对iPad也适用吗?

Iphone 这对iPad也适用吗?,iphone,image,ipad,load,Iphone,Image,Ipad,Load,如何在iPad上实现这一点?它在iphone上运行良好,但苹果要求所有应用程序都应在ipad上运行。有什么帮助吗 - (IBAction)chooseImage:(id)sender { self.imagePicker = [[UIImagePickerController alloc] init]; self.imagePicker.delegate = self; [self.imagePicker setSourceType:U

如何在iPad上实现这一点?它在iphone上运行良好,但苹果要求所有应用程序都应在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];

}

以下是我在《UIImagePickerController》一书中的部分:

好的,对不起,没有通用代码。但它在架构上的工作方式与MPMediaPickerController的工作方式相同,为此,我给出了如何在iPhone和iPad上执行此操作的代码:

这很棘手,因为popover管理与现有的视图控制器管理非常不同。这段代码向你展示了一些你必须担心的事情

下面是我刚刚编写的一个通用应用程序的实际代码:

- (IBAction)doPickAPicture:(id)sender {

    UIImagePickerControllerSourceType type = UIImagePickerControllerSourceTypePhotoLibrary;
    BOOL ok = [UIImagePickerController isSourceTypeAvailable:type];
    if (!ok) {
        return;
    }
    UIImagePickerController* picker = [UIImagePickerController new];
    picker.sourceType = type;
    picker.mediaTypes = @[(__bridge NSString*)kUTTypeImage];
    picker.delegate = self;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        [self presentViewController:picker animated:YES completion:nil];
    else {
        UIPopoverController* pop = [[UIPopoverController alloc] initWithContentViewController:picker];
        [pop presentPopoverFromRect:[sender bounds] inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        self.currentPop = pop;
    }
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    if (self.currentPop && self.currentPop.popoverVisible) {
        [self.currentPop dismissPopoverAnimated:YES];
    } else {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    [CATransaction setCompletionBlock:^{
        self.currentPop = nil;
        // do more stuff
    }];
}

您的应用程序是仅限于iPhone还是通用?如果它只是iPhone,那么您的代码就可以了。如果它是通用的,那么您必须在
UIPopoverController
中显示照片库图像选择器,如
UIImagePickerController
文档中所述。我的应用程序仅适用于iphone,在iphone上可以完美运行。但令我惊讶的是,在appstore中使用该应用时,他们显然要求所有应用都支持iPad。所以我想知道我是否可以在不改变通用的情况下遵守这一点?只要你没有做一些特定的事情来搞乱它,一个只支持iPhone的应用程序就可以在iPad上运行。在popover中使用照片库图像选择器的要求仅适用于iPad专用应用程序或在iPad上运行的通用应用程序。碰巧出现在iPad上的仅适用于iPhone的应用程序没有此要求。你对公布的代码没问题。是的,他(又)说了什么。他们真的在打你还是你只是在编造这些担忧?我不确定,我制作了一个应用程序,它可以拍摄图像,让用户以某种方式修改,然后发送到另一个应用程序。该应用被拒绝,因为审核人没有安装其他应用,所以他认为我的应用坏了。还有一件事是,评论员正在iPad上测试它,当我在家尝试时,我发现imagepicker在iPad上无法工作。所以,即使我的应用程序是一个仅限iphone的应用程序,我也在尝试调整。我很沮丧,所以我现在想不清楚。