4

iOS 7 using UIImagePickerController to take picture twice, at second time will show a static image covered the camera, how to reset the camera.

I'm try to take picture one by one, and keep take 5 pictures.

It works on iOS6.

on iOS7, it works fine at the first time, but when it take picture at second time, it will show a static dark image on screen, how to clear or reset it, although take picture works, but user can't see what will capture with camera.

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];
}

Update

I change the dismiss function to put the [self tackImage]; in block. And now it always show the fist image took.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    NSLog(@"====== imagePicker: didFinish ======");

    self.imagePickerController = nil;

    [self dismissViewControllerAnimated:NO completion: ^{
        [self tackImage];
    }];
}

I'm trying to find a way to clear the image. But I don't know where the image saved yet.

Update2

use

[self performSelector:@selector(presentCameraView) withObject:nil afterDelay:1.0f];

and function

-(void)presentCameraView{
    [self presentViewController:self.imagePickerController animated:NO completion:nil];
}

to replace. [self presentViewController:self.imagePickerController animated:NO completion:nil]; it works on my device anyway, but I don't even know why.

Update3

I have set the userInteractionEnabled to NO when Delay:1.0f to avoid other problems, and may be also need set the navigationBar and tabBar for specifically use.

JerryZhou
  • 4,566
  • 3
  • 37
  • 60
  • I have read this [Presenting a modal view controller immediately after dismissing another](http://stackoverflow.com/questions/3919845/presenting-a-modal-view-controller-immediately-after-dismissing-another), test something now – JerryZhou Sep 26 '13 at 01:45
  • the black camera issue is pretty common, i have a question regarding it also.. if you get to a conclussion, please can you tell me, will do the same http://stackoverflow.com/questions/19081701/ios-7-uiimagepickercontroller-has-black-preview – Heavy_Bullets Sep 29 '13 at 18:48
  • @Heavy_Bullets yes, I sent a bug report to apple, and wait for feedback. Any result will let you know. – JerryZhou Oct 10 '13 at 02:53
  • I did too, but they ask me for a example project... i can't reproduce the issue (if i could, it would not be an issue), if anyone has an example, let me know – Heavy_Bullets Oct 10 '13 at 21:06
  • @Heavy_Bullets, I have create a simple demo app which can reproduce my problem, and attach to bug report. I just build it with one develop profile, not sure if it right or not. Just waiting response from apple. – JerryZhou Oct 11 '13 at 02:15
  • cool, let me know if any responses arise – Heavy_Bullets Oct 11 '13 at 02:16
  • @Heavy_Bullets BugReport replay me that it's a duplicate bug which already reported to apple. So just waiting now. And according to Apple support, adding duplicate bugs does indeed increase their priority internally. Hope more guys to send bug about this. – JerryZhou Oct 17 '13 at 01:49

1 Answers1

0

I had exactly the same issue under iOS 7 using Xamarin.iOS.

What has helped, is adding GC.Collect() in didFinishPickingMediaWithInfo method. In C# GC.Collect() "cleans up" the memory from unused/disposed objects.

For sure, there's no direct equivalent for that in Obj-C, but that may shed some light on your problem also (it could be memory-related).

Shaddix
  • 5,901
  • 8
  • 45
  • 86
  • Thanks, I think it's kind of memory-related problem, and looks like the image is not clean up quickly, but anyway. I remember that some one make the Image picker controller himself, and it works, so I think the problem is about the apple's Image picker controller. – JerryZhou Dec 30 '13 at 01:43