我正在使用的代码允许应用程序只运行一次相机或照片库。我已经使用不同的索引在 actionSheet 上实现了这两个操作。使用相机或照片库挑选图像,但只是第一次。第二次如果用户尝试使用这些操作中的任何一个......应用程序在这个特定点崩溃: -
self.imagePickerController.sourceType = sourceType;
可能是什么原因?包含此代码的方法如下: -
- (void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType {
self.imagePickerController.sourceType = sourceType;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
// user wants to use the camera interface
self.imagePickerController.showsCameraControls = NO;
if ([[self.imagePickerController.cameraOverlayView subviews] count] == 0)
{
// setup our custom overlay view for the camera
// ensure that our custom view's frame fits within the parent frame
CGRect overlayViewFrame = self.imagePickerController.cameraOverlayView.frame;
CGRect newFrame = CGRectMake(0.0,
CGRectGetHeight(overlayViewFrame) -
self.view.frame.size.height - 10.0,
CGRectGetWidth(overlayViewFrame),
self.view.frame.size.height + 10.0);
self.view.frame = newFrame;
[self.imagePickerController.cameraOverlayView addSubview:self.view];
}
}
}