Return to Video

03-15 Preparing for the Challenge Apps

  • 0:00 - 0:03
    Now you're ready to write
    your own delegates.
  • 0:03 - 0:04
    The challenge app for
  • 0:04 - 0:07
    this lesson has three text
    fields with customized behavior.
  • 0:07 - 0:12
    A zip code text field that only allows
    digits with a maximum of five digits.
  • 0:12 - 0:15
    A dollar sign text field that begins
    with the text for zero cents.
  • 0:15 - 0:19
    And then fills in the dollar
    figure as digits are added.
  • 0:19 - 0:24
    And finally, a text field that can only
    be edited when this switch is set to on.
  • 0:24 - 0:28
    Here in the first field, once I get
    to five digits, I can't type anymore.
  • 0:29 - 0:32
    Here in the second field,
    the digits fill in from right to left.
  • 0:32 - 0:35
    And there are always two
    digits beyond the decimal.
  • 0:35 - 0:40
    By the way, don't forget that
    Cmd+k toggles the keyboard.
  • 0:40 - 0:43
    In the third field, the user has to
    flip this switch in order to add text.
  • 0:45 - 0:48
    You can see that tapping
    inside the first two fields
  • 0:48 - 0:51
    brings up the number pad
    instead of the qwerty keyboard.
  • 0:51 - 0:54
    You can set this in the attribute
    inspector in storyboard.
  • 0:54 - 0:56
    Actually, let's open up
    the utilities pane and
  • 0:56 - 0:59
    take a minute to explore
    the attribute inspector.
  • 0:59 - 1:03
    This is a super convenient way to
    configure UIkit view components.
  • 1:03 - 1:05
    Here you can set your placeholder text.
  • 1:05 - 1:09
    So you might want to put something like,
    type your zip code here.
  • 1:09 - 1:12
    Here you can configure the clear button
    like the one you saw in the Safari
  • 1:12 - 1:14
    search bar.
  • 1:14 - 1:16
    Here you can set capitalization.
  • 1:16 - 1:18
    If you add something
    like a confirmation code,
  • 1:18 - 1:20
    you might want all characters
    to be capitalized.
  • 1:20 - 1:25
    And here's the keyboard type, which for
    the zip code we want set to number pad.
  • 1:25 - 1:28
    And just two more tips before
    you move on to the challenge.
  • 1:28 - 1:31
    You're going to need to set
    the delegates for your text fields.
  • 1:31 - 1:34
    If you want to do this in Storyboard
    remember your delegate is
  • 1:34 - 1:35
    just a property.
  • 1:35 - 1:38
    So you're going to look for it in
    Storyboard where you always look for
  • 1:38 - 1:41
    properties in the pop-up
    connections menu.
  • 1:41 - 1:44
    And here under outlets you
    can see your delegate.
  • 1:44 - 1:48
    Also for manipulating text,
    you might want to revisit these
  • 1:48 - 1:51
    few lines of code from
    the emoji text field delegate.
  • 1:51 - 1:55
    The NSString class has the method named
    string by replacing characters in range.
  • 1:55 - 1:58
    It's perfect to use in
    a UI text field delegate.
  • 1:58 - 2:02
    This method is helpful when you need
    to build new strings from typed input.
  • 2:02 - 2:07
    In order to use this method, SWF strings
    are usually used to cast to NSStrings.
  • 2:07 - 2:07
    In this case,
  • 2:07 - 2:10
    the variable newText represents
    the text that will be displayed.
Title:
03-15 Preparing for the Challenge Apps
Description:

03-15 Preparing for the Challenge Apps

more » « less
Video Language:
English
Team:
Udacity
Project:
UD788 - UIKit Fundamentals
Duration:
02:11
There has been no activity on this language so far.

English subtitles

Revisions Compare revisions