-1

I am trying to remove the image picker from view, without success.

What happens is that at the start i see all user albums, than i pick one and edit the image, than the delegate being called, and i dismiss the controller, but i than see again the albums view, and i just can't remove it from the controller .

Here is how i add it :

 pickerLibrary = [[UIImagePickerController alloc] init];
    pickerLibrary.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    pickerLibrary.delegate = self;
     pickerLibrary.allowsEditing=YES;
    pickerLibrary.mediaTypes= [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];


    [self presentViewController:pickerLibrary animated:YES completion:nil];

And on the delegate i do :

 [self dismissViewControllerAnimated:YES completion:^
         {

              //till here works fine, but than go back to albums page, here i have tried :

             [self dismissViewControllerAnimated:YES completion:nil];
             [pickerLibrary.view removeFromSuperView];

             //or even setting a timer and than try to close it .

        }];
Curnelious
  • 1
  • 16
  • 76
  • 150
  • Check to see if calling dismissViewController on the presenting view controller works. If you look at the apple documentation it says, The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller. – Sandeep May 25 '14 at 16:28

1 Answers1

-1

Ok ,seems that the method - (void)viewDidLoad is being called again after i dismiss the images picker, than he load again the view controller .

Solution is to set a boolean for that .

The reason in the first place i have put it in view appear is because you get a warning if its in the view did load . (see link)

A reference to this answer can be seen here :

whose view is not in the window hierarchy

Community
  • 1
  • 1
Curnelious
  • 1
  • 16
  • 76
  • 150