Quote:
Originally Posted by priyahari
Hi,
I have a RootViewController(UINavigationController) and inside this I am trying to programmatically create a UIViewController with few text fields. This UIViewController is created and pushed in when a button is clicked.
I need a method to be called when this UIViewController appears. I cannot use viewdidload or viewwillappear since it all points to rootviewcontroller. Is there any other way to do this without any button click on UIViewController?
Thanks!
|
You said "I cannot use viewdidload or viewwillappear since it all points to rootviewcontroller."
That doesn't make any sense. Each view controller is it's own entity, with it's own methods.
When your navigation controller pushes a new view controller, that new view controller;s different methods get called. It will get an initWithNibName, then a viewDidLoad call, then a viewWillAppear, and finally, once the view controller's views are on-screen, it will get a viewDidAppear message. There are no doubt more methods that get called - I'm summarizing.
If you want your new view controller to notify the parent view controller once it's on-screen, add code to the child view controller's viewDidAppear method that sends a message to the parent view controller. Done.
EDIT: It's pretty clear from your questions that you are just starting to figure out how to use navigation controllers and view controllers. This is a "how do I add 1+1" question, and does not belong in the advanced discussion forum.