Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Alex Puray
Alex Puray
1,304 Points

ViewDidAppear with UIImagePickerController.

Is there a way to do a ViewDidAppear with UIImagePickerController when switching to another view? all I get is the camera reloading after I press the "use" button. Help would be much appreciated! Thank you.

2 Answers

Not sure what you mean, you want viewWillAppear to get called when a presented UIImagePikerController has a button pressed?

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

If I understand correctly, tapping Use causes the UIImagePickerController to disappear, but then it appears again because you are presenting it in viewWillAppear? If you proceed with the course, you will find that we wrap the call to present the UIImagePickerController in an if statement that prevents it from showing again:

if (self.image == nil && [self.videoFilePath length] == 0) {

Have you implemented any code in imagePickerController:didFinishPickingMediaWithInfo:? That gets called when you tap Use. You can set a property or something in that method that you can check in the viewWillAppear or viewDidAppear methods.

Hope this helps!