ios Programming:The Big Nerd Ranch Guid(6th Edition) (Joe Conway & AARON HILLEGASS 著)

Introduction (已看)

  Prerequisites

  What Has Changed in the Sixth Edition?

  Our Teaching Philosophy

  How to Use This Book

  How This Book Is Ogranized

  Style Choices

  Typographical Conventions

  Necessary Hardware and Software

1. A Simple ios Application (已看)

  Creating an Xcode Project

  Designing Quiz

  Interface Builder

  Building the Interface

    Creating view objects

    Configuring view objects

    Running on the simulator

    A brief introduction to Auto Layout

    Making connections

  Creaging the Model Layer

    Implementing action methods

    Loading the first question

  Building the Finished Application

    Application Icons

    Launch Screen

 1 import UIKit
 2 
 3 class ViewController: UIViewController {
 4 
 5     @IBOutlet var questionLabel: UILabel!
 6     @IBOutlet var answerLabel: UILabel!
 7     
 8     let questions: [String] = [
 9         "From what is cognac made?",
10         "What is 7+7?",
11         "What is the capital of Vermont?"
12     ]
13     let answers: [String] = [
14         "Grapes",
15         "14",
16         "Montpelier"
17     ]
18     var currentQuestionIndex: Int = 0
19     
20     override func viewDidLoad() {
21         super.viewDidLoad()
22         questionLabel.text = questions[currentQuestionIndex]
23     }
24     
25     @IBAction func showNextQuestion(_ sender: UIButton) {
26         currentQuestionIndex += 1
27         if currentQuestionIndex == questions.count {
28             currentQuestionIndex = 0
29         }
30         
31         let question: String = questions[currentQuestionIndex]
32         questionLabel.text = question
33         answerLabel.text = "???"
34     }
35     
36     
37     @IBAction func showAnswer(_ sender: UIButton) {
38         let answer: String = answers[currentQuestionIndex]
39         answerLabel.text = answer
40     }
41 
42 }
ViewController

2. The Swift Language (已看)

  Types in Swift

  Using Standard Types

    Inferring types

    Specifying types

    Literals and subscripting

    Initializers

    Properties

    Instance methods

  Optionals

    Subscripting dictionaries

  Loops and String Interpolation

  Enumerations and the Switch Statement

    Enumerations and raw values

  Exploring Apple's Swift Documentation

3. View and the View Hierarchy (已看)

  View Basics

  The View Hierarchy

  Creating a New Project

  View and Frames

    Customizing the labels

  The Auto Layout System

    The alignment rectangle and layout attributes

    Constraints

    Adding constraints in Interface Builder

    Intrinsic content size

    Misplaced views

    Adding more constraints

  Bronze Challenge:More Auto Layout Practice

4. Tex Input and Delegation (已看)

  Text Editing

    Keyboard attributes

    Responding to text fiedl changes

    Dismissing the keyboard

  Implementing the Temperature Conversion

    Number formatters

  Delegation

    Conforming to a protocol

    Using a delegate

    More on protocols

  Bronze Challenge:Disallow Alphabetic Characters

 1 import UIKit
 2 
 3 class ConversionViewController:UIViewController,UITextFieldDelegate{
 4     @IBOutlet var celsiusLabel:UILabel!
 5     @IBOutlet var textField:UITextField!
 6     
 7     override func viewDidLoad(){
 8         super.viewDidLoad()
 9         
10         updateCelsiusLabel()
11     }
12     
13     var fahrenheitValue:Measurement<UnitTemperature>?{
14         didSet{
15             updateCelsiusLabel()
16         }
17     }
18     var celsiusValue:Measurement<UnitTemperature>? {
19         if let fahrenheitValue = fahrenheitValue {
20             return fahrenheitValue.converted(to: .celsius)
21         } else {
22             return nil
23         }
24     }
25     
26     func updateCelsiusLabel(){
27         if let celsiusValue = celsiusValue {
28             celsiusLabel.text = numberFormatter.string(from:NSNumber(value:celsiusValue.value))
29         } else {
30             celsiusLabel.text = "???"
31         }
32     }
33     
34     @IBAction func fahrenheitFieldEditingChanged(_ texField:UITextField){
35         if let text = textField.text,let value = Double(text){
36             fahrenheitValue = Measurement(value:value,unit:.fahrenheit)
37         } else {
38             fahrenheitValue = nil
39         }
40     }
41     
42     @IBAction func dismissKeyboard(_ sender:UITapGestureRecognizer){
43         textField.resignFirstResponder()
44     }
45     
46     let numberFormatter:NumberFormatter = {
47         let nf = NumberFormatter()
48         nf.numberStyle = .decimal
49         nf.minimumFractionDigits = 0
50         nf.maximumFractionDigits = 1
51         return nf
52     }()
53     
54     func textField(_ textField:UITextField, shouldChangeCharactersIn range:NSRange,replacementString string:String)->Bool{
55         let existingTextHasDecimalSeparator = textField.text?.range(of:".")
56         let replacementTextHasDecimalSeparator = string.range(of:".")
57         
58         if existingTextHasDecimalSeparator != nil,replacementTextHasDecimalSeparator != nil {
59             return false
60         } else {
61             return true
62         }
63     }
64 }
ConversionViewController

5. View Controllers (已看)

  The View of a View Controller

  Setting the Initial View Controller

  UITabBarController

    Tab bar items

  Loaded and Appearing Views

    Accessing subviews

  Interacting with View Controllers and Their Views

  Silver Challenge:Dark Mode

  For the More Curious:Retina Display

 1 import UIKit
 2 
 3 class ConversionViewController:UIViewController,UITextFieldDelegate{
 4     @IBOutlet var celsiusLabel:UILabel!
 5     @IBOutlet var textField:UITextField!
 6     
 7     override func viewDidLoad(){
 8         super.viewDidLoad()
 9         
10         print("ConversionViewController loaded its view.")
11         
12         updateCelsiusLabel()
13     }
14     
15     var fahrenheitValue:Measurement<UnitTemperature>?{
16         didSet{
17             updateCelsiusLabel()
18         }
19     }
20     var celsiusValue:Measurement<UnitTemperature>? {
21         if let fahrenheitValue = fahrenheitValue {
22             return fahrenheitValue.converted(to: .celsius)
23         } else {
24             return nil
25         }
26     }
27     
28     func updateCelsiusLabel(){
29         if let celsiusValue = celsiusValue {
30             celsiusLabel.text = numberFormatter.string(from:NSNumber(value:celsiusValue.value))
31         } else {
32             celsiusLabel.text = "???"
33         }
34     }
35     
36     @IBAction func fahrenheitFieldEditingChanged(_ texField:UITextField){
37         if let text = textField.text,let value = Double(text){
38             fahrenheitValue = Measurement(value:value,unit:.fahrenheit)
39         } else {
40             fahrenheitValue = nil
41         }
42     }
43     
44     @IBAction func dismissKeyboard(_ sender:UITapGestureRecognizer){
45         textField.resignFirstResponder()
46     }
47     
48     let numberFormatter:NumberFormatter = {
49         let nf = NumberFormatter()
50         nf.numberStyle = .decimal
51         nf.minimumFractionDigits = 0
52         nf.maximumFractionDigits = 1
53         return nf
54     }()
55     
56     func textField(_ textField:UITextField, shouldChangeCharactersIn range:NSRange,replacementString string:String)->Bool{
57         let existingTextHasDecimalSeparator = textField.text?.range(of:".")
58         let replacementTextHasDecimalSeparator = string.range(of:".")
59         
60         if existingTextHasDecimalSeparator != nil,replacementTextHasDecimalSeparator != nil {
61             return false
62         } else {
63             return true
64         }
65     }
66 }
ConversionViewController
 1 import UIKit
 2 
 3 class MapViewController:UIViewController {
 4     
 5     override func viewDidLoad(){
 6         super.viewDidLoad()
 7         
 8         
 9         print("MapViewController loaded its view.")
10     }
11 }
MapViewController

6. Programmatic Views (已看)

  Creaing a View Programatically

  Programmatic Constraints

    Anchors

    Activating constraints

    Layout guides

    Margins

    Explicit constraints

  Programmatic Controls

  Bronze Challenge:Another Tab

  Silver Challenge:User's Location

  Gold Challenge:Dropping Pins

  For the More Curious:NSAutoresizingMaskLayoutConstraint

 1 import UIKit
 2 
 3 class ConversionViewController:UIViewController,UITextFieldDelegate{
 4     @IBOutlet var celsiusLabel:UILabel!
 5     @IBOutlet var textField:UITextField!
 6     
 7     override func viewDidLoad(){
 8         super.viewDidLoad()
 9         
10         print("ConversionViewController loaded its view.")
11         
12         updateCelsiusLabel()
13     }
14     
15     var fahrenheitValue:Measurement<UnitTemperature>?{
16         didSet{
17             updateCelsiusLabel()
18         }
19     }
20     var celsiusValue:Measurement<UnitTemperature>? {
21         if let fahrenheitValue = fahrenheitValue {
22             return fahrenheitValue.converted(to: .celsius)
23         } else {
24             return nil
25         }
26     }
27     
28     func updateCelsiusLabel(){
29         if let celsiusValue = celsiusValue {
30             celsiusLabel.text = numberFormatter.string(from:NSNumber(value:celsiusValue.value))
31         } else {
32             celsiusLabel.text = "???"
33         }
34     }
35     
36     @IBAction func fahrenheitFieldEditingChanged(_ texField:UITextField){
37         if let text = textField.text,let value = Double(text){
38             fahrenheitValue = Measurement(value:value,unit:.fahrenheit)
39         } else {
40             fahrenheitValue = nil
41         }
42     }
43     
44     @IBAction func dismissKeyboard(_ sender:UITapGestureRecognizer){
45         textField.resignFirstResponder()
46     }
47     
48     let numberFormatter:NumberFormatter = {
49         let nf = NumberFormatter()
50         nf.numberStyle = .decimal
51         nf.minimumFractionDigits = 0
52         nf.maximumFractionDigits = 1
53         return nf
54     }()
55     
56     func textField(_ textField:UITextField, shouldChangeCharactersIn range:NSRange,replacementString string:String)->Bool{
57         let existingTextHasDecimalSeparator = textField.text?.range(of:".")
58         let replacementTextHasDecimalSeparator = string.range(of:".")
59         
60         if existingTextHasDecimalSeparator != nil,replacementTextHasDecimalSeparator != nil {
61             return false
62         } else {
63             return true
64         }
65     }
66 }
ConversionViewController
 1 import UIKit
 2 import MapKit
 3 
 4 class MapViewController:UIViewController {
 5     
 6     var mapView:MKMapView!
 7     
 8     override func loadView(){
 9         // Create a map view
10         mapView = MKMapView()
11         
12         // Set it as *the* view of this view controller
13         view = mapView
14         
15         let segmentedControl = UISegmentedControl(items:["Standard","Hybrid","Satellite"])
16         segmentedControl.backgroundColor = UIColor.white.withAlphaComponent(0.5)
17         segmentedControl.selectedSegmentIndex = 0
18         segmentedControl.translatesAutoresizingMaskIntoConstraints = false
19         
20         view.addSubview(segmentedControl)
21         
22         //let topConstraint = segmentedeControl.topAnchor.constraint(equalTo:view.topAnchor)
23         let topConstraint = segmentedControl.topAnchor.constraint(equalTo:topLayoutGuide.bottomAnchor,constant:8)
24         
25         let margins = view.layoutMarginsGuide
26         let leadingConstraint = segmentedControl.leadingAnchor.constraint(equalTo:margins.leadingAnchor)
27         let trailingConstraint = segmentedControl.trailingAnchor.constraint(equalTo:margins.trailingAnchor)
28         
29         segmentedControl.addTarget(self,action: #selector(MapViewController.mapTypeChanged(_:)),for: .valueChanged)
30         
31         topConstraint.isActive = true
32         leadingConstraint.isActive = true
33         trailingConstraint.isActive = true
34     }
35     
36     
37     override func viewDidLoad(){
38         super.viewDidLoad()
39         
40         
41         print("MapViewController loaded its view.")
42     }
43     
44     @objc func mapTypeChanged(_ segControl:UISegmentedControl){
45         switch segControl.selectedSegmentIndex{
46         case 0:
47             mapView.mapType = .standard
48             break;
49         case 1:
50             mapView.mapType = .hybrid
51             break;
52         case 2:
53             mapView.mapType = .satellite
54             break;
55         default:
56             break;
57         }
58     }
59 }
MapViewController

7. Localization (已看)

  Internationalization

    Formatters

    Base internationalization

    Preparing for localization

  Localization

    NSLocalizedString and strings tables

  Bronze Challenge:Another Localization

  For the More Curious:Bundle's Role in Internationalization

  For the More Curious:Improting and Exporting as XLIFF

8. Controlling Animations

  Basic Animations

    Closures

  Another Label

  Animation Completion

  Animating Constraints

  Timing Functions

  Bronze Challenge:Spring Animations

  Silver Challenge:Layout Guides

9. Debugging

  A Buggy Project

  Debugging Basics

    Interpreting console messages

    Fixing the first bug

    Caveman debugging

  The Xcode Debugger:LLDB

    Setting breakpoints

    Stepping through code

    The LLDB console

10. UITableView and UITableViewController

  Beginning the Homepwner Application

  UITableViewController

    Subclassing UITableViewController

  Creating the Item Class

    Custom initializers

  UITableView's Data Source

    Giving the controller access to the store

    Implementing data source methods

  UITableViewCells

    Creating and retrieving UITableViewCells

    Reusing UITableViewCells

  Content Insets

  Bronze Challenge:Sections

  Silver Challenge:Constant Rows

  Gold Challenge:Customizing the Table

11. Editing UITableView

  Editing Mode

  Adding Rows

  Deleting Rows

  Moving Rows

  Displaying User Alerts

  Design Patterns

  Bronze Challenge:Renaming the Delete Button

  Silver Challenge:Preventing Reordering

  Gold Challenge:Really Preventing Reordering

12. Subclassing UITableViewCell

  Creating ItemCell

  Exposing the Properties of ItemCell

  Using ItemCell

  Dynamic Cell Heights

  Dynamic Type

    Responding to user changes

  Bronze Challenge:Cell Colors

13. Stack Views

  Using UIStackView

    Implicit constraints

    Stack view distribution

    Nested stack views

    Stack view spacing

  Segues

  Hooking Up the Content

  Passing Data Around

  Bronze Challenge:More Stack Views

14. UINavigationController

  UINavigationController

    Navigating with UINavigationController

    Appearing and Disappearing Views

    Dismissing the Keyboard

      Event handling basics

      Dismissing by pressing the Return key

      Dismissing by tapping elsewhere

    UINavigationBar

      Adding buttons to the navigation bar

    Bronze Challenge:Displaying a Number Pad

    Silver Challenge:A Custom UITextField

    Gold Challenge:Pushing More View Controllers

15. Camera

  Displaying Images and UIImageView

    Adding a camera button

  Taking Pictures and UIImagePickerController

    Setting the image picker's sourceType

    Setting the image picker's delegate

    Presenting the image picker modally

    Permissions

    Saving the image

  Creating ImageStore

  Giving View Controllers Access to the Image Store

  Creating and Using Keys

  Wrapping Up ImageStore

  Bronze Challenge:Editing an Image

  Silver CHallenge:Removing and Image

  Gold Challenge:Camera Overlay

  For the More Curious:Navigating Implementation Files

    // MARK:

16. Saving,Loading,and Application States

  Archiving

  Application Sandbox

    Constructing a file URL

  NSKeyedArchiver and NSKeyedUnarchiver

    Loading files

  Application States and Transitions

  Writing to the FileSystem with Data

  Error Handling

  Bronze Challenge:PNG

  For the More Curious:Application State Transitions

  For the More Curious:Reading and Writing to the Filesystem

  For the More Curious:The Application Bundle

17. Size Classes

  Modifying Traits for a Specific Size Class

  Bronze Challenge:Stacked Text Field and Labels

18. Touch Events and UIResponder

  Touch Events

  Creating the TouchTracker Application

  Creating the Line Struct

    Structs

    Value types vs reference types

  Creating DrawView

  Drawing with DrawView

  Turning Touches into Lines

    Handling multiple touches

  @IBInspectable

  Silver Challenge:Colors

  GoldChallenge:Circles

  For the More Curious:The Responder Chain

  For the More Curious:UIControl

19. UIGestureRecognizer and UIMenuController

  UIGestureRecognizer Subclasses

  Detecting Taps with UITapGestureRecognizer

  Multiple Gesture Recognizers

  UIMenuController

  More Gesture Recognizers

    UILongPressGestureRecognizer

    UIPanGestureRecognizer and simultaneous recognizers

  More on UIGestureRecognizer

  Silver Challenge:Mysterious Lines

  Gold Challenge:Speed and Size

  Platinum Challenge:Colors

  For the More Curious:UIMenuController and UIResponderStandardEditActions

20. Web Services

  Starting the Photorama Application

  Building the URL

    Formatting URLs and requests

    URLComponents

  Sending the Request

    URLSession

  Modeling the Photo

  JSON Data

    JSONSerialization

    Enumerations and associated values

    Parsing JSON data

  Downloading and Displaying the Image Data

  The Main Thread

  Bronze Challenge:Printing the Response Information

  Silver Challenge:Fetch Recent Photos from Flickr

  For the More Curious:HTTP

21. Collection Views

  Displaying the Grid

  Collection View Data Source

  Customizing the Layout

  Creating a Custom UICollectionViewCell

  Downloading the Image Data

    Extensions

    Image caching

  Navigating to a Photo

  Silver Challenge:Updated Item Sizes

  Gold Challenge:Creating a Custom Layout

22. Core Data

  Object Graphs

  Entities

    Modeling entities

    Transformable attributes

    NSManagedObject and subclasses

  NSPersistentContainer

  Updating Items

    Inserting into the context

    Saving changes

  Updating the Data Source

    Fetch requests and predicates

  Bronze Challenge:Photo View Count

  For the More Curious:The Core Data Stack

    NSManagedObjectModel

    NSPersistentStoreCoordinator

    NSManagedObjectContext

23. Core Data Relationships

  Relationships

  Adding Tags to the Interface

  Background Tasks

  Silver Challenge:Favorites

24. Accessibility

  VoiceOver

    Testing VoiceOver

    Accessibility in Photorama

25. Afterword

  What to Do Next

  Shameless Plugs

转载于:https://www.cnblogs.com/revoid/p/8421341.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值