UIImagepickerController [takepicture]模态视图消失没有委托回调 [英] UIImagepickerController [takepicture] modal view disappears no delegate callback

查看:268
本文介绍了UIImagepickerController [takepicture]模态视图消失没有委托回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:

这已被回答。这是我自己的愚蠢,可能不值得再读这个问题。 lol。

This has been answered. It was my own stupidity, possibly not worth reading any more of this question. lol.

问题:

右键,所以我有这个UIViewController(主)子类,它有一个UIImagepickerController相机),它也有一个UIView(overlayView)。主机将摄像机配置为仅使用自定义摄像机覆盖的摄像机,隐藏自定义控件。

Right so i have this UIViewController(master) subclass, it has a UIImagepickerController(camera), it also has a UIView(overlayView). Master setups the camera to be configured as a camera only with a custom cameraOverlay, hiding the custom controls e.t.c.

除了我尝试以编程方式拍摄照片之外,所有操作都可以正常工作。发生什么是overlayView调用主人,这触发拍摄照片,然后我听到快门声音和光圈关闭,相机似乎关闭自己(我有点不愿在我的代码这样做),然后我的viewDidAppear被调用我的主人了。

All appears to work fine apart from when i try to programatically take a picture. What happens is the overlayView calls the master and this triggers the take picture, then i hear the shutter sound and the iris closes, the camera appears to dismiss itself (i am defiantly not doing this in my code) and then my viewDidAppear gets called in my master again.

任何人都知道发生了什么事情。

Anybody have any idea whats going on ?

    -(void)viewDidLoad
{
    NSLog(@"loading the view");
    //if the camera is on the device
    if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
    {
        //make one
        camera = [[UIImagePickerController alloc] init];
        //setup some settings that we need
        camera.sourceType = UIImagePickerControllerSourceTypeCamera;
        camera.showsCameraControls = NO;
        camera.navigationBarHidden = NO;
        camera.toolbarHidden = YES;
        camera.cameraViewTransform = CGAffineTransformScale(camera.cameraViewTransform, 1.03, 1.03);
        //show it
        overlayView = [[OverlayView alloc] initWithFrame:CGRectMake(0,0,320,480) withDelegate:self andController:self];
        camera.cameraOverlayView = overlayView;
            camerashowing=NO;

    }
    else 
    {
        alert = [[UIAlertView alloc] initWithTitle:@"No Camera Detected" message:@"The camera is broken or your device has no camera. Please close the application" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }
}

-(void)viewDidAppear:(BOOL)animated
{
  if (!cameraShowing)
  {
    NSLog(@"going to show camera");
    [self presentModalViewController:camera animated:NO];
    camerashowing = YES;
  }
}



 -(void)releaseShutter
  { 
    [overlayView toolbarShowWarning];
    NSLog(@"going to show camera: %@", self);
    [camera takePicture]; 

    }

在答案中的一些帮助建议后,我可以说相机未被释放。

After some help advice from people in the answers i can say that the camera is not being released.

我还通过检查viewDidAppear方法中的bool值,设法停止exec_bad_access,停止它第二次调用[presentmodal ....]。

I have also managed to stop the exec_bad_access by stopping it from calling [presentmodal....] for a second time by checking a bool value in the viewDidAppear Method.

我仍然遇到模态视图消失的问题,任何帮助,再次lol ??

I still have the issue where the modal view disapears, any help, again lol ??

推荐答案

我想你缺少一个 camera.delegate = self;

这篇关于UIImagepickerController [takepicture]模态视图消失没有委托回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆