I have a Modal View Controller, and a Navigation View Controller embedded in a normal View Controller. Now, when someone clicks a UIBarButtonItem on my Navigation Bar, they go to the modal view controller. I have a custom UIAlertView which is a loading bar for retrieving the data for my app. I put this in the ViewWillAppear method. The problem is that if someone goes into the modal view controller and goes back to the navigation controller, the UIAlertView pops up again. Is there any way that I can make a method happen ONLY on launch? Any help would be appreciated. Thanks!
Here’s some more info: I originally had it in ViewDidLoad (instead of ViewDidAppear), and the same thing kept appearing. I have a feeling that I might be doing something wrong with the implementing the modal view controller. I have my own custom navigation bar, so I’m hiding the normal navigation bar and I’m programmatically calling performSeguewithIdentifier.
ViewDidLoad will fire every time your view loads, which can be more than once per session (i.e. a memory leak that released views). What I would do is create a boolean instance variable and in your init method set it to true. Then check to see that this boolean var is true before showing your alert view (either from viewWillAppear or viewDidLoad).
For example:
This ensures that your alert will only be shown once per session. Unless for some reason your ViewController should be released. In which case, you should store this BOOL in the AppDelegate.h class.