我的带有相机的 UIImagePickerController 很奇怪

发布于 2024-08-31 04:48:41 字数 674 浏览 1 评论 0原文

我在 iPhone 上通过划痕使用相机时遇到问题。其他人的代码在我的 3GS 上运行良好,但我的代码却不能。

当我实现 UIViewController 控制器时,我在 viewdidload 中添加以下代码:

UIImagePickerController *picker = [UIImagePickerController alloc] init];
picker.source = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self; //Previously added all the delegate properly
[self presentModalViewController:picker animated:YES];

什么也没有出现。 我检查了调试器,它显示选择器已分配,但这是我的和成功的之间的主要区别。

picker._imagepickerflag.visible = 0;  //others show 1;
picker.UINavigationController._containerView: 0x0 ;  // others have value.

谁能帮我解决这个问题,有什么问题吗?

谢谢。

I met a problem on using camera by scratch on iphone. Other people's code just run fine on my 3GS, but my code doesn't.

When I implemented a UIViewController controller, and I add the following code in viewdidload:

UIImagePickerController *picker = [UIImagePickerController alloc] init];
picker.source = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self; //Previously added all the delegate properly
[self presentModalViewController:picker animated:YES];

Nothing comes out.
I checked in the debugger, it shows that the picker is allocated, but here is the major difference between my and success one.

picker._imagepickerflag.visible = 0;  //others show 1;
picker.UINavigationController._containerView: 0x0 ;  // others have value.

Can anyone help me on this, is there something wrong?

Thank you.

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

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

发布评论

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

评论(1

意中人 2024-09-07 04:48:41
UIImagePickerController *picker = [UIImagePickerController alloc] init];

上面的代码是错误的。应该是

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

下面这个也是错误的。

picker.source = UIImagePickerControllerSourceTypeCamera;

它应该是

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

并且一旦它被呈现你就应该释放它。

[picker release];

希望有帮助。

UIImagePickerController *picker = [UIImagePickerController alloc] init];

Above code is wrong. It should be

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

This below is also wrong.

picker.source = UIImagePickerControllerSourceTypeCamera;

it should be

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

And you should release it once it has been presented.

[picker release];

Hope that helps.

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