iOS 7 は UIImagePickerController を使用して 2 回写真を撮ります。
1枚ずつ撮って、5枚撮り続けます。
iOS6で動作します。
iOS7 では、最初は正常に動作しますが、2 回目に写真を撮ると、画面に静的な暗い画像が表示され、それをクリアまたはリセットする方法が表示されます。カメラでキャプチャします。
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];
、ブロック内に配置します。そして今、それは常に最初に撮った画像を表示します。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(@"====== imagePicker: didFinish ======");
self.imagePickerController = nil;
[self dismissViewControllerAnimated:NO completion: ^{
[self tackImage];
}];
}
私はイメージをクリアする方法を見つけようとしています。しかし、画像がどこに保存されているかはまだわかりません。
Update2
使用する
[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];
とにかく私のデバイスで動作しますが、その理由もわかりません。
Update3
userInteractionEnabled
他の問題を回避するために をNO
whenに設定しましたが、特に使用するためにおよびをDelay:1.0f
設定する必要がある場合もあります。 navigationBar
tabBar