从iPhone中的另一个viewcontroller中解除ModalViewController

时间:2009-09-13 19:13:21

标签: iphone cocoa-touch

新的3.1 sdk允许UIImagepickerController隐藏相机控件并通过cameraOverlay视图使用您自己的控件。所以,我通过另一个Viewcontroller实现了叠加视图:

CameraViewController *cameraController = [[CameraViewController alloc] initWithNibName:@"CameraViewController" bundle:nil];
self.cameraviewController = cameraController;

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraOverlayView = cameraviewController.view;
picker.showsCameraControls = NO;
[self presentModalViewController:picker animated:YES];
[cameraController release];
[picker release];

cameraviewController.view有“取消”按钮。我面临的问题是如何使用该取消按钮关闭模态视图。我还没有找到一种引用调用Modalview的控制器的方法。

非常感谢提前

1 个答案:

答案 0 :(得分:1)

需要添加cameraController.delegate = self;并在CameraViewController中设置委托协议。