Adding our button action
Our next step is to add the code to be called when the Add New button is pressed. In our previous chapter, we created an action called addNewPressed
and connected it to our Add New button. Let's go ahead and write the code to present the proper view controller when this button is pressed. First, switch to MenuViewController.h
, and directly underneath the standard #import
for UIKit, let's import our view controllers as shown in the following code snippet:
#import <UIKit/UIKit.h> #import "AddNewViewController.h" #import "MyFoodsViewController.h" #define ADD_NEW_VIEW_CONTROLLER @"AddNew"
We have also defined a string literal for our storyboard ID for good practice. We have named it ADD_NEW_VIEW_CONTROLLER
so that we know what it contains. Switch back to MenuViewController.m
and scroll down to our addNewPressed
method. As we will be presenting this view controller (dragging it onto the screen from the bottom), we need to also create a navigation controller to hold...