The first thing we want to do is give the user the ability to add additional food items from this view. The best way to do this is to add a button in the navigation bar. Apple provides a system button to add items that will be displayed as a nice plus button. Switch to MyFoodsViewController.m
and scroll down to the viewDidLoad
method. Add the following code:
// Set our views title self.title = @"MY FOODS"; // Create the plus button UIBarButtonItem *plusButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)]; // Assign the bar buttons to the navigation controller [self.navigationItem setRightBarButtonItem:plusButton]; // Set this in every view controller so that the back button displays the back button only without the viewcontroller name self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:nil action:nil];
Here, we...