更新:
这已经回答了。这是我自己的愚蠢,可能不值得再读这个问题了。哈哈。
问题:
对,所以我有这个 UIViewController(master) 子类,它有一个 UIImagepickerController(camera),它还有一个 UIView(overlayView)。Master将相机设置为仅具有自定义cameraOverlay的相机,隐藏自定义控件等
除了我尝试以编程方式拍照之外,一切似乎都很好。发生的情况是overlayView调用主控并触发拍照,然后我听到快门声音并且光圈关闭,相机似乎自行关闭(我在我的代码中坚决不这样做)然后我的viewDidAppear被调用又是我的主人。
有人知道发生了什么吗?
-(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];
}
在得到人们的一些帮助建议后,我可以说相机没有被释放。
我还设法通过检查 viewDidAppear 方法中的布尔值来阻止 exec_bad_access 第二次调用 [presentmodal....]。
我仍然有模态视图消失的问题,任何帮助,再次大声笑?