2

我就是不明白:

我怎么能在 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];

}

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

4

2 回答 2

3
  1. 不要释放imagePickerController两次。
  2. 你会用[self dismissModalViewControllerAnimated:YES];
于 2010-11-22T15:00:42.820 回答
1

不要释放它两次并在释放它之前将其关闭。(就像 ole 说的)

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

于 2010-11-22T15:12:18.167 回答