Giter Site home page Giter Site logo

score-keeper's Introduction

Score-Keeper

A simple iOS app with a single scroll view with score fields and stepper buttons.

###Step 1: Create a Navigation Controller

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

###Step 2: Set the ScrollView and Title

  • Add a scrollView property to your class
  • Initialize the scrollView and add it to the main view of scoreViewController
  • Set the title of the view controller "Score Keeper"

###Step 3: Create an addScoreView method that takes an integer (index)

  • Create an addScoreView method that will add a UIView to the scrollView
  • In the method Initialize a UIView called view
  • Initialize a UITextField for name, a UILabel for score, and a UIStepper for a button
  • Lay them out by setting their frames in the new view
  • Add that view to the scrollview
  • You'll want to adjust the properties of each of those controls:
    • Placeholder text for the textfields
    • Min and max values for the stepper

###Step 4: Store your scoreLabels

  • Create a mutable array property called scoreLabels
  • In the addScoreView method set the tag of your stepper to the index you passed in
  • In the addScoreView method add the scoreLabel to your scoreLabels array

###Step 5: Add a target action to the stepper

  • Create an action method for when the score stepper value changes
  • Add self as target for the control event ValueChanged to the score stepper
  • In the action method capture the value of the stepper
  • Get the label from the array of labels that is at the index matching the tag of stepper
  • Update the text of the label to match the value of the stepper

###Step 6: Dismiss the keyboard when done editing name

  • Set self as the delegate of the nameTextField
  • Add a textFieldShouldReturn delegate method
  • In that method have the textField resign firstResponder

###Black Diamond

  • Add buttons that add and remove score rows

    • Create an array property that holds views
    • Store your scoreView in the array at the end of the addScoreView method
    • Create a removeLastScore method
      • Grab the last view in the scoreViews array and remove it from the view
      • Remove that object from the scoreViews array
    • Add 2 UIButtons as class properties
    • Create an updateButtonView method
      • In the updateButton method check to see if they have already been initialized
        • If they haven't, initialize them and add them to the scrollview
        • Give the addScore button a title "Add Score"
          • Add self as the target of the addScore button and call the addScoreView method with controlEvent TouchUpInside
        • Give the removeScore button a title "Remove Score"
          • Add self as the target of the removeScore button and call the removeLastScore method with controlEvent TouchUpInside
      • Set the frames of the buttons based on the number of views in the scoreView array, so that they are always below the scores
    • Update the scrollViewContentSize based on the number of views in the scoreView array plus the add/remove buttons
  • Allow the user to edit score in the scoreTextField

    • Change the scoreLabel to a ScoreTextField
    • Set the scoreTextField enabled to YES
    • Set self as the delegate of the scoreTextField
    • Add a textFieldShouldReturn delegate method
    • In the method check if the textField's tag is -1 (which means it's a name field)
    • If the textField's tag is not -1, get the score stepper at the index of the textField's tag
    • Update the value of the score stepper to the double value of the text

score-keeper's People

Contributors

calebhicks avatar jakeherrmann04 avatar jkhowland avatar

Stargazers

 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

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.