需要帮助处理(解雇)objective-c (iphone) 中的 ImagePicker (相机)
我在忽略相机视图时遇到了一些问题。 我使用 UIImagePickerController 与此代码 -
-(void)viewDidAppear:(BOOL)animated{
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls=NO;
[picker.cameraOverlayView addSubview:mirrorOverlay];
picker.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:picker animated:YES];
[picker release];}
我使用自定义按钮关闭相机并使用此代码将视图更改回我的主视图 -
-(IBAction)flipBack:(id)sender{
[self dismissModalViewControllerAnimated:YES];
我的问题是当我按下“视图翻转”按钮,然后返回并再次调用相机。 我找不到一种方法来消除相机和视图。
请帮忙。 谢谢, 阿米尔。
更新: 感谢您的帮助!我明白了! 我的问题是我正在使用相机的 nib 文件,当您想以委托上描述的不同方式使用相机时,您应该使用 View 而不是 nib。
所以我的代码是正确的,但位置和格式错误。 谢谢大家!
如果有人需要帮助,我会在这里提供帮助!
i have a little problem with dismissing my camera view.
im using the UIImagePickerController with this code-
-(void)viewDidAppear:(BOOL)animated{
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls=NO;
[picker.cameraOverlayView addSubview:mirrorOverlay];
picker.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:picker animated:YES];
[picker release];}
im using a custom button to close the camera and change the view back to my main view using this code-
-(IBAction)flipBack:(id)sender{
[self dismissModalViewControllerAnimated:YES];
my problem is when im pressing the button the View flipout and then going back in and call the camera again.
i can't find a way to dismiss the camera and the view.
Please help.
Thanks,
Amir.
Update:
Thanks for the help ! i figure it out !
my problem was that i was working with nib files of the camera, and when you want to use the camera in different way that was described on the delegate you should use View and not nib.
so my code was correct but in the wrong place and format.
Thanks all !
if someone need help with it, I'm here to help back !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
在 iOS7 中,不推荐使用相机胶卷图像选择器呈现/关闭 ModalViewController。
要打开图像选择器,请使用:
[controller presentViewController:mediaUI animated:YES completion:nil]; // open image picker
要关闭或取消图像选择器,请使用:
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil]; // close image picker
}
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您需要关闭选择器,从外观上看,您正在关闭呈现选择器的控制器。
在这种情况下,您需要保留对
picker
的引用(例如:添加 UIImagePicker *picker; 作为 viewcontroller 类的成员)。you need to dismiss the picker, by the looks of it you're dismissing the controller that presents the picker.
You need to keep a reference to the
picker
in this case (e.g: add UIImagePicker *picker; as a member to your viewcontroller class).