十月第四周
2018-10-26 本文已影响133人
玉思盈蝶
十月第四周
1.Swift的map:
potStructs.map { PotMaterial($0) }
https://www.cnblogs.com/muzijie/p/6542650.html
2.Swift Precondition 预处理:
https://www.cnblogs.com/QianChia/p/8673714.html
3.iOS 优化ipa包,减小安装包大小:
https://www.jianshu.com/p/a49d59b01669
https://www.jianshu.com/p/a72d03e92c80
4.设置页面横竖屏:
class AppDelegate: UIResponder, UIApplicationDelegate {
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 {
// 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 -> viewDidAppear
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