弹出窗口中的 ImagePicker 不会隐藏
我读过,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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个问题是方法
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 bedidFinishPickingMediaWithInfo
(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];
.