如何关闭imagePickerController?
我就是不明白:
我到底怎样才能在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
imagePickerController
两次。[selfmissModalViewControllerAnimated:YES];
关闭它imagePickerController
twice.[self dismissModalViewControllerAnimated:YES];
不要释放它两次,并在释放之前将其关闭。 (就像 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.