Git Product home page Git Product logo

recipe-app's Introduction

Recipe-App

An iOS app that displays some favorite recipes from Recipe.com

##Lesson 3: TableView DataSource

###Step 1: Create a Navigation Controller

  • Clone down this project (or create a new single view controller in Xcode)
  • Create a UIViewController called RecipeViewController
  • In the AppDelegate didFinishLaunching method initialize a UINavigationController with a recipeViewController instance as the rootViewController
  • Make the navigationController the rootViewController of the window.

Step 2: Add a tableview to the view

  • Add a UITableView as a property on the viewController class
  • Initialize and add the tableView as a subview of the main view

Step 3: Import the RARecipes model into your app

Choose internal or external datasource and follow the applicable Step 4

Step 4 (External Datasource): Create a new tableViewDatasource

  • Create a NSObject subclass called RecipesTableViewDataSource
  • In the header file, adopt the UITableViewDataSource protocol
  • Add the required UITableViewDataSource methods to the implementation file
  • In numberOfRows return RARecipes class method count
  • in cellForRowAtIndexPath return a cell with the textLabel.text set to the string RARecipes class titleAtIndex for indexPath.row

Step 4 (Internal Datasource): Implement the tableViewDatasource

  • In the viewController, adopt the UITableViewdataSource protocol
  • Add the required UITableViewDataSource methods to the implementation file
  • In numberOfRows return RARecipes class method count
  • in cellForRowAtIndexPath return a cell with the textLabel.text set to the string RARecipes class titleAtIndex for indexPath.row

Black Diamond

  • Add the description of each recipe in small text on the main view

Lesson 4: TableView Delegate

Step 5: Setting Up the Delegate

  • In the RecipeViewController, adopt the UITableViewDelegate protocol
  • Add the didSelectRowAtIndexPath:(NSIndexPath *)indexPath method to enable cell selection
  • In the didSelectRowAtIndexPath: method, tell the tableView to deselect the cell to remove the highlight
  • Create a new ViewController class called RecipeDetailViewController
  • Instantiate your new RecipeDetailViewController and present it using the RecipeViewController's UINavigationController

Step 6: Set Up the DetailViewController

Setting up the DetailViewController is your opportunity to incorporate a lot of the work with UIView that we have done so far. You will use a ScrollView to display the details of the recipe. Feel free to reference the solution code for hints on setting up the DetailViewController.

  • Add a public property @property (nonatomic, assign) NSInteger recipeIndex to your RecipeDetailViewController, this will be used to connect the correct Recipe Details to the DetailViewController
  • Set the title of the DetailViewController to the [RARecipes titleAtIndex:], you should retrieve the titleAtIndex using the index property
  • Initialize a UIScrollView that will hold all of your labels for details on the Recipe
  • Set a topMargin variable that can be used to separate the labels
  • Add a description label, ingredients labels, and direction labels, use the solution code as a reference, do not copy and paste, but use it to learn how a developer must think about laying out views
  • You will need a method that returns the height for a given string, look in the documentation for NSString (hint: use the boundingRectWithSize: method to return how tall your block of text will be so you can properly set your subviews)

This can be overwhelming and difficult. Enjoy the learning process. Ask your mentor for help.

Step 7: Updating Your DetailViewController With the Correct Recipe

We need to pass the indexPath.row of the selected cell to the DetailViewController's index property that we created so that the DetailViewController knows what recipe to display

  • In your didSelectRowAtIndexPath: method in your RecipeViewController, set the public index property of the DetailViewController to the indexPath.row of the selected cell

Black Diamonds

  • Stylize the detail view. Fonts, layout, color.
  • Can you add an imageview to the top of the recipe detail view?

recipe-app's People

Contributors

calebhicks avatar jakeherrmann04 avatar jkhowland avatar trm36 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.