Reputation: 85096
I have created a very basic "Hello world" application where I am trying to switch between two Views that are in a single story board. When I get to the second view I would like to execute a function. I believe the way to do this is to make a call to the function from didViewLoad
in the second view.
My issue is that when I drag/dropped my second view onto my story board it did not autogenerate the NewViewController.h
or NewViewController.m
files (these exist for the default view).
Does the approach I described above sound like the correct way to execute a function on view load? If so, how would I go about having the .m
and .h
files created?
Disclaimer - This is my first iOS app so if anything I have said here does not make sense please let me know.
Upvotes: 0
Views: 1365
Reputation: 1365
Choose "create new file" in files inspector. Choose ios - cocoa - UIViewController Subclass, type name of class (ExampleViewController), uncheck "with XIB file"(because we have one(storyboard file)). Create.
Then do everything you want in viewDidLoad function in ExampleViewController.m.
Finally, open storyboard file, choose this second viewController, then choose third tab in right pane "identity inspector", then type "ExampleViewController" in "Class" field. Now we link our ExampleViewController with interface. (carefull! choose viewcontroller, not smth on it)
Upvotes: 3