Question: I have button which when I click displays the camera (works perfectly) 

```
- (IBAction)getPhoto:(id)sender
{
    NSLog( @"Button clicked!" );
    imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    }

    else {  // IF the device doesn't have a camera, so use the photos album
        [imagePicker setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
    }

    [self addSubview:imagePicker.view];
}

```

After which I can take an image, etc, - But when I click "use" : nothing happens here is my method : the Image picker does not dismiss itslelf : the application simply does nothing, I'm trying to take the image I just took and display it inside a CGRect on screen .

```
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissViewControllerAnimated:YES completion:NULL];

    UIImageView *patientImage = [[UIImageView alloc] init];
    patientImage.frame = CGRectMake(625, 25, 83, 103);

    UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    self.patientImage.image = chosenImage;
}

```

Even when I hit the cancel button without taking an image, the imagePicker (camera interface) does not dismiss itself 

Any help, advice, or guidance would be very appreciated.

Answer: 
Try: 

```
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker.view removeFromSuperview];

    UIImageView *patientImage = [[UIImageView alloc] init];
    patientImage.frame = CGRectMake(625, 25, 83, 103);

    UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    self.patientImage.image = chosenImage;
}

```
Remove the `[self.addSubView:imagePicker.view];` and instead 

`[self presentViewController:imagePicker animated:YES completion:NULL];`

You are dismissing the variable `picker` although `picker` is undefined. Instead put:

`[self dismissModalViewControllerAnimated:YES completion:NULL];` 
and make sure its at the end of your method.