iOS 7 使用 UIImagePickerController 拍照两次,第二次会显示一个静态图像覆盖在相机上,如何重置相机。
我正在尝试一张一张地拍照,并保持拍摄5张照片。
它适用于iOS6。
在iOS7上,第一次可以正常,但是第二次拍照时,屏幕上会显示静态的暗图像,如何清除或重置它,虽然可以拍照,但用户看不到会发生什么用相机捕捉。
bool fistTimeToShow = YES;
-(void) viewDidAppear:(BOOL)animated{
if (fistTimeToShow) {
fistTimeToShow = NO;
self.imagePickerController = nil;
[self tackImage];
}
}
-(void)tackImage{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imagePickerController = [[UIImagePickerController alloc]init];
self.imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imagePickerController.showsCameraControls = YES;
self.imagePickerController.delegate = self;
[self presentViewController:self.imagePickerController animated:NO completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(@"====== imagePickerController:didFinishPickingMediaWithInfo ======");
[self.imagePickerController dismissViewControllerAnimated:NO completion:nil];
//...deal with the image capture...
self.imagePickerController = nil;
[self tackImage];
}
更新
我更改了关闭功能以放置[self tackImage];
in 块。现在它总是显示拍摄的第一张照片。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(@"====== imagePicker: didFinish ======");
self.imagePickerController = nil;
[self dismissViewControllerAnimated:NO completion: ^{
[self tackImage];
}];
}
我正在尝试找到一种清除图像的方法。但我不知道图像保存在哪里。
更新2
利用
[self performSelector:@selector(presentCameraView) withObject:nil afterDelay:1.0f];
和功能
-(void)presentCameraView{
[self presentViewController:self.imagePickerController animated:NO completion:nil];
}
取代。[self presentViewController:self.imagePickerController animated:NO completion:nil];
无论如何它都可以在我的设备上运行,但我什至不知道为什么。
更新3
我已经设置了userInteractionEnabled
to NO
whenDelay:1.0f
以避免其他问题,并且可能还需要设置navigationBar
andtabBar
以供专门使用。