Reputation: 195
I'm wondering if there is a method that would call when a view controller is loaded to the screen.
As an example, the user presses a button and a second view controller loads. When the view controller appears, it runs a function automatically.
Upvotes: 0
Views: 943
Reputation: 1414
There are several methods you can use in a ViewController to run functions depending when you need them to run. In your case, you should use
-(void) viewDidAppear:(BOOL)animated
This will run once the viewController is appearing on the screen. Be sure to also call [super viewDidAppear:animated]
inside the method.
Other methods that may come in handy:
-(void) viewDidLoad
-(void) viewWillAppear:(BOOL)animated
-(void) viewWillDisappear:(BOOL)animated
-(void) viewDidDisappear:(BOOL)animated
Upvotes: 2