【发布时间】:2017-04-02 00:30:32
【问题描述】:
我有一个自定义的UIImagePickerController 效果很好,只是我面临一个我认为应该相当简单的问题 - 我还没有找到解决方案。
触摸我自定义添加的“照片”按钮后,我将其定位到 UIIPC 的 takePicture 方法中的构建。这是我的代码
@interface CustomCameraController ()
@end
@implementation CustomCameraController {
CGFloat width, height;
}
- (instancetype)init {
if (self = [super init]) {
width = self.view.frame.size.width, height = self.view.frame.size.height;
self.allowsEditing = YES;
self.sourceType = UIImagePickerControllerSourceTypeCamera;
self.showsCameraControls = NO;
self.toolbarHidden = YES;
[self buildCameraOverlay];
}
return self;
}
- (void)buildCameraOverlay {
UIView *customOverlay = [UIView alloc] ...
// ... Custom overlay setup done here
_takePhoto = [[CustomButton alloc] initWithFrame:CGRectMake(0, 0, heightBottomBar*.5, heightBottomBar*.5)];
_takePhoto.center = CGPointMake(bottomBar.frame.size.width/2, bottomBar.frame.size.height/2);
[_takePhoto setImage:[UIImage imageNamed:@"camera button icon"] forState:UIControlStateNormal];
[_takePhoto addTarget:self action:@selector(takePicture) forControlEvents:UIControlEventTouchUpInside];
[bottomBar addSubview:_takePhoto];
// ...
self.cameraOverlayView = customOverlay;
}
这是在我的自定义控制器 CustomCameraController init 调用中完成的。
问题是,通过takePicture 拍照时,相机快门关闭,一切正常,但控制器自行关闭。我试图弄清楚如何在拍照后立即阻止它关闭,所以我可以 A) 展示拍摄的照片,并且 B) 让用户可以选择图像或取消并重新拍摄另一张图像(返回相机)
如果有人知道为什么会发生这种情况或我遗漏/做错了什么,请告诉我。我敢肯定这是一个简单的答案 - 只是似乎无法弄清楚。谢谢!
【问题讨论】:
-
能否提供
takePicture方法的代码以及UIImagePickerController的委托方法? -
....... 委托问题。我觉得很傻。
-
如果您愿意,请将设置 del 设置为答案,我会接受,否则我将删除这个愚蠢的问题
-
别担心,这发生在我们最好的人身上。我会尽快发布答案,以便人们快速参考。
标签: ios objective-c uiimagepickercontroller ios-camera