十月第四周

# 十月第四周
1.Swift的map:html

```
potStructs.map { PotMaterial($0) }
```
https://www.cnblogs.com/muzijie/p/6542650.htmlapp

2.Swift Precondition 預處理:
https://www.cnblogs.com/QianChia/p/8673714.htmlide

3.iOS 優化ipa包,減少安裝包大小:
https://www.jianshu.com/p/a49d59b01669優化

https://www.jianshu.com/p/a72d03e92c80ui

4.設置頁面橫豎屏:編碼

```
class AppDelegate: UIResponder, UIApplicationDelegate {htm

var window: UIWindow?

// 頁面的橫豎屏 當前界面支持的方向(默認狀況下只能豎屏,不能橫屏顯示)
var interfaceOrientations: UIInterfaceOrientationMask = .portrait {
didSet {
// 強制設置成豎屏
if interfaceOrientations == .portrait {
UIDevice.current.setValue(UIDeviceOrientation.portrait.rawValue, forKey: "orientation")
}
// 強制設置成橫屏
else if !interfaceOrientations.contains(.portrait) {
UIDevice.current.setValue(UIDeviceOrientation.landscapeLeft.rawValue, forKey: "orientation")
}
}
}

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return interfaceOrientations
}對象

// 使用
class DetailViewController1: UIViewController {blog

// Applegate對象
let appDelegate = UIApplication.shared.delegate as! AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.white
setupUI()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// 該頁面橫豎屏切換
appDelegate.interfaceOrientations = .allButUpsideDown
}

override func viewWillDisappear(_ animated: Bool) {
// 退出頁面強制豎屏
appDelegate.interfaceOrientations = .portrait
}
```
5.didMoveToSuperView和didMoveToWindow的調用順序:
didMoveToSuperView -> viewWillAppear -> didMoveToWindow -> viewDidAppearip

6.正確使用可選類型:
https://www.jianshu.com/p/448cf4f8cf65

7.Git正確使用分支:
不須要每次都從新拉取建立新分支,新功能才須要建立新分支。
功能分支合到主分支要及時的刪除無用的分支,以避免分支太多影響管理。

8.獲取UUID:

```
let UUID:String = ASIdentifierManager.shared().advertisingIdentifier.uuidString

```
9.屬性.classForCoder:
編碼器快捷類。

```print(self.view.classForCoder)```輸出:UIView

相關文章
相關標籤/搜索