ios笔记

字数 1640 · 2019-01-24

#ios

The App Delegate Source File

The AppDelegate.swift source file has two primary functions:

  • It defines your AppDelegate class. The app delegate creates the window where your app’s content is drawn and provides a place to respond to state transitions within the app.

  • It creates the entry point to your app and a run loop that delivers input events to your app. This work is done by the UIApplicationMain attribute (@UIApplicationMain), which appears toward the top of the file.

Using the UIApplicationMain attribute is equivalent to calling the UIApplicationMain function and passing your AppDelegate class’s name as the name of the delegate class.

In response, the system creates an application object. The application object is responsible for managing the life cycle of the app. The system also creates an instance of your AppDelegate class, and assigns it to the application object. Finally, the system launches your app.

The AppDelegate class is automatically created whenever you create a new project. You should use this class provided by Xcode to initialize your app and respond to app-level events.

The AppDelegate class adopts the UIApplicationDelegate protocol. This protocol defines a number of methods you use to set up your app, to respond to the app’s state changes, and to handle other app-level events.

The AppDelegate class contains a single property: window.

1
var window: UIWindow?

This property stores a reference to the app’s window. This window represents the root of your app’s view hierarchy. It is where all of your app content is drawn. Note that the window property is an optional, which means it may have no value (be nil) at some point.

Storyboard

A storyboard is a visual representation of the app’s user interface, showing screens of content and the transitions between them.

Xcode provides a library of objects that you can add to a storyboard file. Some of these are elements that appear in the user interface, such as buttons and text fields. Others, such as view controllers and gesture recognizers, define the behavior of your app but don’t appear onscreen.

The elements that appear in the user interface are known as views. Views display content to the user.

All view objects in iOS are of type UIView or one of its subclasses.

In general, each scene has its own view hierarchy. At the top of each view hierarchy is a content view.

Auto Layout is a powerful layout engine that helps you design adaptive layouts that dynamically respond to any changes to the scene’s size.

You describe your layout using constraints — rules that explain where one element should be located relative to another, or what size the element should be. Auto Layout dynamically calculates the size and position of each element based on these constraints.

In a storyboard, a scene represents one screen of content and typically one view controller. View controllers implement your app’s behavior. A view controller manages a single content view with its hierarchy of subviews.

All view controller objects in iOS are of type UIViewController or one of its subclasses.

1
@IBOutlet weak var nameTextField: UITextField!

The IBOutlet attribute tells Xcode that you can connect to the nameTextField property from Interface Builder.

The ! at the end of the type declaration indicates that the type is an implicitly unwrapped optional.

When a view controller is loaded from a storyboard, the system instantiates the view hierarchy and assigns the appropriate values to all the view controller’s outlets. By the time the view controller’s viewDidLoad() method is called, the system has assigned valid values to all of the controller’s outlets, and you can safely access their contents.

iOS apps are based on event-driven programming.

1
2
@IBAction func setDefaultLabelText(_ sender: UIButton) {
}

view controller life cycle

iOS calls the UIViewController methods as follows:

  • viewDidLoad() - Called when the view controller’s content view (the top of its view hierarchy) is created and loaded from a storyboard. The view controller’s outlets are guaranteed to have valid values by the time this method is called.

  • viewWillAppear() - Called just before the view controller’s content view is added to the app’s view hierarchy. Use this method to trigger any operations that need to occur before the content view is presented onscreen.

  • viewDidAppear() - Calledcv just after the view controller’s content view has been added to the app’s view hierarchy. Use this method to trigger any operations that need to occur as soon as the view is presented onscreen, such as fetching data or showing an animation.

  • viewWillDisappear() - Called just before the view controller’s content view is removed from the app’s view hierarchy. Use this method to perform cleanup tasks like committing changes or resigning the first responder status.

  • viewDidDisappear() - Called just after the view controller’s content view has been removed from the app’s view hierarchy. Use this method to perform additional teardown activities.

Gesture recognizers are objects that you attach to a view that allow the view to respond to the user the way a control does.

Buttons have five different states: normal, highlighted, focused, selected, and disabled.

Buttons always start in the normal state. A button is highlighted whenever the user touches it.The focused state is used by focus-based interfaces, like Apple TV.

Debug

iOS Safari

safari iOS
6.0 6.0 - 6.1.6
7.0 7.0.3 - 7.1.2
8.0 8.0 - 8.4.1
9.0 9.0 - 9.3.6
10.0 10.0 - 10.3.4
11.0 11.0 - 11.4.1
12.0 - 12.1.2 12.0 - 12.4.1
13.0 - 13.1 13.0 - 13.4
14.0 14.0

https://en.wikipedia.org/wiki/Safari_version_history#iOS

iPhone initial OS latest OS
iPhone 5 iOS 6.0 iOS 10.3.4
iPhone 5C iOS 7.0 iOS 10.3.3
iPhone 5S iOS 7.0 iOS 12.5
iPhone 6 / 6 Plus iOS 8.0 iOS 12.5
iPhone 6S / 6S Plus iOS 9.0 iOS 14.3
iPhone SE1 iOS 9.3 iOS 14.3
iPhone 7 / 7Plus iOS 10.0 iOS 14.3
iPhone 8 / 8Plus iOS 11.0 iOS 14.3
iPhone X iOS 11.0.1 iOS 14.3
iPhone XS / XS Max / XR iOS 12.0 iOS 14.3
iPhone 11 / 11Pro / 11Pro Max iOS 13.0 iOS 14.3
iPhone SE2 iOS 13.4 iOS 14.3
iPhone 12 / 12 Pro iOS 14.1 iOS 14.3
iPhone 12 Mini iOS 14.2 iOS 14.3
iPhone 12 Pro Max iOS 14.2 iOS 14.3
iPad initial OS lastest OS Released
iPad 4 6.0 10.3.4 2012.11
iPad 5 10.2.1 14.3 2017.3
iPad 6 11.3 14.3 2018.3
iPad 7 13.1 14.3 2019.9
iPad 8 14.0 14.3 2020.9
iPad Mini 1 6.0 9.3.5 2012.11
iPad Mini 2 7.0.3 12.5 2013.11
iPad Mini 3 8.1 12.5 2014.10
iPad Mini 4 9.0 14.3 2015.9
iPad Mini 5 12.2 14.3 2019.3
iPad Air 1 7.0.3 12.5 2013.11
iPad Air 2 8.1 14.3 2014.10
iPad Air 3 12.2 14.3 2019.3
iPad Air 4 14.0 14.3 2020.10
iPad Pro 9.7 1st 9.3 14.3 2016.3
iPad Pro 10.5 1st 10.3.2 14.3 2017.11
iPad Pro 11 1st 12.1 14.3 2018.11
iPad Pro 11 2st 12.1 14.3 2020.3
iPad Pro 12.9 1st 9.1 14.3 2015.11
iPad Pro 12.9 2nd 10.3.2 14.3 2017.6
iPad Pro 12.9 3rd 12.1 14.3 2018 .11
iPad Pro 12.9 4th 13.4 14.3 2020.3

https://en.wikipedia.org/wiki/List_of_iOS_and_iPadOS_devices