弹出窗口中的 ImagePicker 不会隐藏

发布于 2024-10-31 14:53:31 字数 1525 浏览 12 评论 0原文

我读过,iPad 必须使用 UIPopoverController 来查看 PhotoLibrary,但是,我编辑了代码来实现它,当我选择图片时,弹出窗口会显示,但不会隐藏。

我发现它没有到达didFinishpickingMediaWithInfo。我错过了什么吗?这是我的代码

-(IBAction) ButtonClicked{

    ipc = [[UIImagePickerController alloc] init];
    ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    ipc.delegate=self;
    popover = [[UIPopoverController alloc] initWithContentViewController:ipc];
    [ipc release];
    [popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 800.0, 400.0) 
                             inView:self.view
           permittedArrowDirections:UIPopoverArrowDirectionAny 
                           animated:YES];   
}

-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    [picker release];
}

这里:

-(void) imagePickerController:(UIImagePickerController *)picker didFinishpickingMediaWithInfo:(NSDictionary *)info{

 // TempImage is a UIImage instance
    TempImg = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    //bgImage is a UIImageView instance and it's connected in the IB
    [bgImage setImage:TempImg];
    // Dismiss UIImagePickerController and release it
    [picker dismissModalViewControllerAnimated:YES];
    [picker.view removeFromSuperview];
    [picker release];
}

我真的需要有人的帮助,我已经观看了每个 youtube 视频,阅读了互联网上的每一篇文章,并尝试了几乎所有内容。我非常感谢你的帮助。

I have read that the iPad must use a UIPopoverController to view the PhotoLibrary, however, I have edited the code to make it, the popover shows but it does not hide when I choose a picture.

I found that it does not reach the didFinishpickingMediaWithInfo. Am I missing anything? here is my code

-(IBAction) ButtonClicked{

    ipc = [[UIImagePickerController alloc] init];
    ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    ipc.delegate=self;
    popover = [[UIPopoverController alloc] initWithContentViewController:ipc];
    [ipc release];
    [popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 800.0, 400.0) 
                             inView:self.view
           permittedArrowDirections:UIPopoverArrowDirectionAny 
                           animated:YES];   
}

here:

-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    [picker release];
}

and here:

-(void) imagePickerController:(UIImagePickerController *)picker didFinishpickingMediaWithInfo:(NSDictionary *)info{

 // TempImage is a UIImage instance
    TempImg = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    //bgImage is a UIImageView instance and it's connected in the IB
    [bgImage setImage:TempImg];
    // Dismiss UIImagePickerController and release it
    [picker dismissModalViewControllerAnimated:YES];
    [picker.view removeFromSuperview];
    [picker release];
}

I really need someone's help, I have already watched every youtube video, read every article on the internet and tried almost everything. I would really appreciate your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜警司 2024-11-07 14:53:31

第一个问题是方法 didFinishpickingMediaWithInfo 拼写错误,因此不会被调用。它应该是 didFinishPickingMediaWithInfo (大写 P 表示拾取)。

第二个问题是在父级上调用解雇,否则选择器将不会隐藏弹出窗口。相反,请尝试调用 [popover DismissPopoverAnimated:YES];

The first problem is that the method didFinishpickingMediaWithInfo is spelled wrong and so it won't get called. It should be didFinishPickingMediaWithInfo (uppercase P for Picking).

Second problem is calling dismiss on the parent or the picker will not hide the popover. Instead, try calling [popover dismissPopoverAnimated:YES];.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文