0

Hi I'm Uploading image form my device to server in the the photo library if user click the cancel button it has to go back to the main view controller but its going to the image pick view please tell to how to go back to main view controller from the photo library I'm using the story board.

    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{

           [self dismissViewControllerAnimated:NO completion:nil];
        }

The above i have used its not working please tell how to make it done.

Thanks

user3349668
  • 147
  • 2
  • 11

3 Answers3

1

you should use picker instead of self, When you photo library appears , its present modelViewController is called and when cancel ,dismissViewController is called as you have shown above. Now if you wan't to move to some other screen you have to use

   [self.navigationController popToViewController:urviewcontroller animated:YES ];

This method should be called after you have dismissed the modelViewController of photo library

Indrajeet
  • 5,490
  • 2
  • 28
  • 43
Rana
  • 451
  • 4
  • 16
  • pls tell me in the popview controller code what is uvir= controlleranimated and tell where i have to put this code. – user3349668 Mar 15 '14 at 04:32
  • my bad, it simply works like this. When you call [self presentViewController:myPicker animated:YES completion:NULL]; and when you are done with either selecting photo from library or cancel you call method [myPicker dismissViewControllerAnimated:YES completion:nil]; Now this above code will show you library and also remove that library once you are done with your selection or cancel. After that if you wan't to move to any viewController use method [self.navigationController popToViewController:yourVC animated:YES ]; yourVC is view controller on you want to move to/ – Rana Mar 15 '14 at 04:34
  • i have committed the [self dismissViewControllerAnimated:NO completion:nil]; and i have used ur code its throwing error like Application tried to present modally an active controller – user3349668 Mar 15 '14 at 04:42
  • you haven't mentioned how you are selcting images from library? , can you write the code for that as well so that we can take a clear look? – Rana Mar 15 '14 at 04:44
  • i have tired using that in popview controller if ihave give the my view controller its showing error unexpected interface name 'myviewcontroller: expected expression – user3349668 Mar 15 '14 at 04:46
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/49787/discussion-between-user3349668-and-rana) – user3349668 Mar 15 '14 at 04:51
  • sorry not able get u which selection code ur asking – user3349668 Mar 15 '14 at 04:53
0

It should be [picker dismissViewControllerAnimated:NO completion:nil];

codercat
  • 22,873
  • 9
  • 61
  • 85
GenieWanted
  • 4,473
  • 4
  • 24
  • 35
0

If you are using presentModalViewController: to present the UIImagePicker then use the dismissModalViewControllerAnimated: to dismiss the presented view.

Jayesh Thanki
  • 2,037
  • 2
  • 23
  • 32
  • once the user press the cancel button i want to dismiss the photo library and its should go to my first view controller not to the image picker – user3349668 Mar 15 '14 at 05:55