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

 import UIKit

 class ViewController: UIViewController {

     @IBOutlet var questionLabel: UILabel!
     @IBOutlet var answerLabel: UILabel!

     let questions: [String] = [
         "From what is cognac made?",
         "What is 7+7?",
         "What is the capital of Vermont?"
     ]
     let answers: [String] = [
         "Grapes",
         ",
         "Montpelier"
     ]

     override func viewDidLoad() {
         super.viewDidLoad()
         questionLabel.text = questions[currentQuestionIndex]
     }

     @IBAction func showNextQuestion(_ sender: UIButton) {
         currentQuestionIndex +=
         if currentQuestionIndex == questions.count {
             currentQuestionIndex =
         }

         let question: String = questions[currentQuestionIndex]
         questionLabel.text = question
         answerLabel.text = "???"
     }

     @IBAction func showAnswer(_ sender: UIButton) {
         let answer: String = answers[currentQuestionIndex]
         answerLabel.text = answer
     }

 }

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

 import UIKit

 class ConversionViewController:UIViewController,UITextFieldDelegate{
     @IBOutlet var celsiusLabel:UILabel!
     @IBOutlet var textField:UITextField!

     override func viewDidLoad(){
         super.viewDidLoad()

         updateCelsiusLabel()
     }

     var fahrenheitValue:Measurement<UnitTemperature>?{
         didSet{
             updateCelsiusLabel()
         }
     }
     var celsiusValue:Measurement<UnitTemperature>? {
         if let fahrenheitValue = fahrenheitValue {
             return fahrenheitValue.converted(to: .celsius)
         } else {
             return nil
         }
     }

     func updateCelsiusLabel(){
         if let celsiusValue = celsiusValue {
             celsiusLabel.text = numberFormatter.string(from:NSNumber(value:celsiusValue.value))
         } else {
             celsiusLabel.text = "???"
         }
     }

     @IBAction func fahrenheitFieldEditingChanged(_ texField:UITextField){
         if let text = textField.text,let value = Double(text){
             fahrenheitValue = Measurement(value:value,unit:.fahrenheit)
         } else {
             fahrenheitValue = nil
         }
     }

     @IBAction func dismissKeyboard(_ sender:UITapGestureRecognizer){
         textField.resignFirstResponder()
     }

     let numberFormatter:NumberFormatter = {
         let nf = NumberFormatter()
         nf.numberStyle = .decimal
         nf.minimumFractionDigits =
         nf.maximumFractionDigits =
         return nf
     }()

     func textField(_ textField:UITextField, shouldChangeCharactersIn range:NSRange,replacementString string:String)->Bool{
         let existingTextHasDecimalSeparator = textField.text?.range(of:".")
         let replacementTextHasDecimalSeparator = string.range(of:".")

         if existingTextHasDecimalSeparator != nil,replacementTextHasDecimalSeparator != nil {
             return false
         } else {
             return true
         }
     }
 }

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

 import UIKit

 class ConversionViewController:UIViewController,UITextFieldDelegate{
     @IBOutlet var celsiusLabel:UILabel!
     @IBOutlet var textField:UITextField!

     override func viewDidLoad(){
         super.viewDidLoad()

         print("ConversionViewController loaded its view.")

         updateCelsiusLabel()
     }

     var fahrenheitValue:Measurement<UnitTemperature>?{
         didSet{
             updateCelsiusLabel()
         }
     }
     var celsiusValue:Measurement<UnitTemperature>? {
         if let fahrenheitValue = fahrenheitValue {
             return fahrenheitValue.converted(to: .celsius)
         } else {
             return nil
         }
     }

     func updateCelsiusLabel(){
         if let celsiusValue = celsiusValue {
             celsiusLabel.text = numberFormatter.string(from:NSNumber(value:celsiusValue.value))
         } else {
             celsiusLabel.text = "???"
         }
     }

     @IBAction func fahrenheitFieldEditingChanged(_ texField:UITextField){
         if let text = textField.text,let value = Double(text){
             fahrenheitValue = Measurement(value:value,unit:.fahrenheit)
         } else {
             fahrenheitValue = nil
         }
     }

     @IBAction func dismissKeyboard(_ sender:UITapGestureRecognizer){
         textField.resignFirstResponder()
     }

     let numberFormatter:NumberFormatter = {
         let nf = NumberFormatter()
         nf.numberStyle = .decimal
         nf.minimumFractionDigits =
         nf.maximumFractionDigits =
         return nf
     }()

     func textField(_ textField:UITextField, shouldChangeCharactersIn range:NSRange,replacementString string:String)->Bool{
         let existingTextHasDecimalSeparator = textField.text?.range(of:".")
         let replacementTextHasDecimalSeparator = string.range(of:".")

         if existingTextHasDecimalSeparator != nil,replacementTextHasDecimalSeparator != nil {
             return false
         } else {
             return true
         }
     }
 }

ConversionViewController

 import UIKit

 class MapViewController:UIViewController {

     override func viewDidLoad(){
         super.viewDidLoad()

         print("MapViewController loaded its view.")
     }
 }

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

 import UIKit

 class ConversionViewController:UIViewController,UITextFieldDelegate{
     @IBOutlet var celsiusLabel:UILabel!
     @IBOutlet var textField:UITextField!

     override func viewDidLoad(){
         super.viewDidLoad()

         print("ConversionViewController loaded its view.")

         updateCelsiusLabel()
     }

     var fahrenheitValue:Measurement<UnitTemperature>?{
         didSet{
             updateCelsiusLabel()
         }
     }
     var celsiusValue:Measurement<UnitTemperature>? {
         if let fahrenheitValue = fahrenheitValue {
             return fahrenheitValue.converted(to: .celsius)
         } else {
             return nil
         }
     }

     func updateCelsiusLabel(){
         if let celsiusValue = celsiusValue {
             celsiusLabel.text = numberFormatter.string(from:NSNumber(value:celsiusValue.value))
         } else {
             celsiusLabel.text = "???"
         }
     }

     @IBAction func fahrenheitFieldEditingChanged(_ texField:UITextField){
         if let text = textField.text,let value = Double(text){
             fahrenheitValue = Measurement(value:value,unit:.fahrenheit)
         } else {
             fahrenheitValue = nil
         }
     }

     @IBAction func dismissKeyboard(_ sender:UITapGestureRecognizer){
         textField.resignFirstResponder()
     }

     let numberFormatter:NumberFormatter = {
         let nf = NumberFormatter()
         nf.numberStyle = .decimal
         nf.minimumFractionDigits =
         nf.maximumFractionDigits =
         return nf
     }()

     func textField(_ textField:UITextField, shouldChangeCharactersIn range:NSRange,replacementString string:String)->Bool{
         let existingTextHasDecimalSeparator = textField.text?.range(of:".")
         let replacementTextHasDecimalSeparator = string.range(of:".")

         if existingTextHasDecimalSeparator != nil,replacementTextHasDecimalSeparator != nil {
             return false
         } else {
             return true
         }
     }
 }

ConversionViewController

 import UIKit
 import MapKit

 class MapViewController:UIViewController {

     var mapView:MKMapView!

     override func loadView(){
         // Create a map view
         mapView = MKMapView()

         // Set it as *the* view of this view controller
         view = mapView

         let segmentedControl = UISegmentedControl(items:["Standard","Hybrid","Satellite"])
         segmentedControl.backgroundColor = UIColor.white.withAlphaComponent(0.5)
         segmentedControl.selectedSegmentIndex =
         segmentedControl.translatesAutoresizingMaskIntoConstraints = false

         view.addSubview(segmentedControl)

         //let topConstraint = segmentedeControl.topAnchor.constraint(equalTo:view.topAnchor)
         let topConstraint = segmentedControl.topAnchor.constraint(equalTo:topLayoutGuide.bottomAnchor,constant:)

         let margins = view.layoutMarginsGuide
         let leadingConstraint = segmentedControl.leadingAnchor.constraint(equalTo:margins.leadingAnchor)
         let trailingConstraint = segmentedControl.trailingAnchor.constraint(equalTo:margins.trailingAnchor)

         segmentedControl.addTarget(self,action: #selector(MapViewController.mapTypeChanged(_:)),for: .valueChanged)

         topConstraint.isActive = true
         leadingConstraint.isActive = true
         trailingConstraint.isActive = true
     }

     override func viewDidLoad(){
         super.viewDidLoad()

         print("MapViewController loaded its view.")
     }

     @objc func mapTypeChanged(_ segControl:UISegmentedControl){
         switch segControl.selectedSegmentIndex{
         :
             mapView.mapType = .standard
             break;
         :
             mapView.mapType = .hybrid
             break;
         :
             mapView.mapType = .satellite
             break;
         default:
             break;
         }
     }
 }

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

ios Programming:The Big Nerd Ranch Guid(6th Edition) (Joe Conway & AARON HILLEGASS 著)的更多相关文章

  1. Objective-C Programming The Big Nerd Ranch Guide 笔记 19-37

    Properties are either atomic or nonatomic, The difference has to do with multithreading. atomic is t ...

  2. iOS Programming UIWebView 2

    iOS Programming  UIWebView 1 Instances of UIWebView render web content. UIWebView可以显示web content. In ...

  3. iOS Programming Web Services and UIWebView

    iOS Programming Web Services and UIWebView The work is divided into two parts. The first is connecti ...

  4. Head First iOS Programming

    内部分享: Head First iOS Programming http://www.slideshare.net/tedzhaoxa/head-first-ios-programming-4606 ...

  5. iOS Programming Recipe 6: Creating a custom UIView using a Nib

    iOS Programming Recipe 6: Creating a custom UIView using a Nib JANUARY 7, 2013 BY MIKETT 12 COMMENTS ...

  6. iOS Programming Autorotation, Popover Controllers, and Modal View Controllers

    iOS Programming Autorotation, Popover Controllers, and Modal View Controllers  自动旋转,Popover 控制器,Moda ...

  7. iOS Programming Controlling Animations 动画

    iOS Programming Controlling Animations 动画 The word "animation" is derived from a Latin wor ...

  8. iOS Programming UIStoryboard 故事板

    iOS Programming UIStoryboard In this chapter, you will use a storyboard instead. Storyboards are a f ...

  9. iOS Programming NSUserDefaults

    iOS Programming NSUserDefaults  When you start an app for the first time, it uses its factory settin ...

随机推荐

  1. 深入理解java虚拟机---jdk8新特性(二)

    1.jdk8新特性 1.新特性 2.lambda函数表达式的作用 A: 替换内部类 B:对集合的操作并行化

  2. 二、求水仙花数,打印出100-999之间所有的"水仙花数"

    所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身. 例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方 public c ...

  3. 基于spec互评Alpha版本

    作业要求[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2323] 队名:二次元梦之队 组长:刘莹莹 组员:周昊 潘世维  王玉潘 赵美增 ...

  4. L267 How to save money

    When it comes to saving money, the struggle is all too real. It's like your bank account and your 20 ...

  5. apache rewrite 规则

    啥是虚拟主机呢?就是说把你自己的本地的开发的机子变成一个虚拟域名,比如:你在开发pptv下面的一个项目 127.0.0.1/pptv_trunk,你想把自己的机器域名变成www.pptv.com.那么 ...

  6. 什么是lambda函数,它有什么好处

    编程中提到的lambda表达式,通常是在需要一个函数,但是又不想费神去命名一个函数的场合下使用,也就是值匿名函数. python允许你定义一种单行的小函数.定义lambda函数的形式如下lambda参 ...

  7. 大直播时代,P2P才是降低成本的必杀技

    在流媒体传输分发领域,CDN和P2P一直是经常被拿来进行对比和讨论的一大热点,虽然不少大型视频企业目前同时使用着CDN和P2P两套分发机制,但相对于CDN,很多人对于P2P技术知之甚少.整体来说,P2 ...

  8. PMP基本概念

    项目是为创造独特的产品,服务或成果而进行的临时性的工作.项目的三个特点是:临时,独特,渐进明细. 运营是遵循组织有流程的重复性工作. 项目组合是为了实现战略目标而组合在一起管理的项目,项目集,子项目组 ...

  9. 对ajax中数据的得到以及绑定的认识

    1.将后台得到的数据绑定到datagrid为例: 第一种是: 后台得到的数据直接绑定到datagrid上面,如下图: 这样操作的好处在于可以使界面比较简洁. 第二种是将得到的数据作为参数的形式绑定到d ...

  10. 【CSP】字符与int

    [转自https://yq.aliyun.com/articles/19153] WIKIOI-1146 ISBN号码   光仔december 2014-03-01 16:20:00 浏览479 评 ...