如何关闭imagePickerController?

发布于 2024-10-03 23:11:03 字数 936 浏览 3 评论 0原文

我就是不明白:

我到底怎样才能在 xcode 上“关闭”imagePickerController? 这是打开相机的代码,它工作得很好。

-(IBAction) startcamera {


imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePickerController.allowsEditing = NO;
imagePickerController.showsCameraControls=NO;
imagePickerController.toolbarHidden=YES ;
imagePickerController.wantsFullScreenLayout=YES;
imagePickerController.cameraOverlayView=self.view;
self.imagePickerController.delegate=self;
    [self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];

}

现在,假设我想通过单击按钮来关闭 imagePickerController(意味着不选择任何图像):我该怎么做? 尝试过:

-(IBAction)closecamera {


[imagePickerController release];
    [imagePickerController dismissModalViewControllerAnimated:YES];

}

但它不起作用! 有什么线索吗? 提前致谢

I just can't get this:

how in the world can I "shut down" imagePickerController on xcode?
This is the code that opens the camera, and it works perfectly..

-(IBAction) startcamera {


imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePickerController.allowsEditing = NO;
imagePickerController.showsCameraControls=NO;
imagePickerController.toolbarHidden=YES ;
imagePickerController.wantsFullScreenLayout=YES;
imagePickerController.cameraOverlayView=self.view;
self.imagePickerController.delegate=self;
    [self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];

}

Ok now, say I want to close imagePickerController by clicking a button (means without picking any image): how am I supposed to do that?
Tried with:

-(IBAction)closecamera {


[imagePickerController release];
    [imagePickerController dismissModalViewControllerAnimated:YES];

}

but it doesn't work!
Any clues?
Thanks in advance

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

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

发布评论

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

评论(2

遥远的她 2024-10-10 23:11:03
  1. 不要释放imagePickerController两次。
  2. 您可以使用 [selfmissModalViewControllerAnimated:YES]; 关闭它
  1. Don't release imagePickerController twice.
  2. You would dismiss it with [self dismissModalViewControllerAnimated:YES];
花期渐远 2024-10-10 23:11:03

不要释放它两次,并在释放之前将其关闭。 (就像 ole 所说)

但这也很重要......一旦你释放了一个对象,它就消失了并且无法调用任何方法。

Don't release it twice and dismiss it before you release it. (like ole said)

But this is also important... as soon as you have released an object it is gone and no methods can be called.

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