如何关闭imagePickerController?

时间:2010-11-22 14:57:20

标签: iphone xcode uiimagepickercontroller dismiss

我无法得到这个:

我可以在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];

}

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

2 个答案:

答案 0 :(得分:3)

  1. 不要发布imagePickerController两次。
  2. 您可以使用[self dismissModalViewControllerAnimated:YES];
  3. 将其解雇

答案 1 :(得分:1)

请勿释放它并在释放之前将其解除。 (比如说Ole)

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