Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mrl72

macrumors regular
Original poster
I have a need to show something to the user as soon as the view has loaded for the first time. So I have a method in viewDidAppear that does this. The problem is whenever I open a modal window in full screen when it returns it always executes viewDidAppear method in the parent controller, which runs my method again. What is the best way to handle this? Is it a simple case of just checking a BOOL value for first time app is loaded, or am I going about this completely the wrong way?

Cheers!
 
I have a need to show something to the user as soon as the view has loaded for the first time.
You sure there's not another method where you could put this, one that gets executed only when the view Did Load (hint, hint)?
 
It's in ViewDidLoad now. Since my method calls a modal window it won't work until the view has appeared.
 
It's in ViewDidLoad now. Since my method calls a modal window it won't work until the view has appeared.

Then, yeah, I think in viewDidAppear with a boolean would be a suitable approach (although I suspect there are others).
 
OK cool. BTW is it normal for the dismissal of a full screen modal window to call the parent ViewDidAppear method anyway? Notice it doesn't do it on the other modal presentation styles.

Cheers.
 
Yes, it's normal. viewWill/DidAppear are called every time a view controller's view appears or is revealed. That means when the view first appears after being pushed or presented and also if a detail view or modal view that was in front of that view goes away.

See the view controller programming guide.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.