Swift开发iOS App学习笔记(一)---AppIcon & Launch
Taylor Guo, 2017年9月16日
需要准备一个图片,实际上是同一幅图片的不同分辨率,所以最好是一副分辨率比较大的图片,比如尺寸为1024,iOS会加载进去。
iOS8之后苹果推荐推荐使用Launch File,而不是Launch Image。
iOS8之后就会在Xcode里面看到Launchscreen.storyboard。
ESTabBarController Github
UITabBarController是容器视图控制器,它包含了一个或多个视图控制器。另外两个容器是Navigation Controller和Split View Controller。
容器关系是用箭头来表示。 参考资料
iOS From Scratch With Swift: Exploring Tab Bar Controller
StoryBoard
运行APP的时候,UIApplication将Tab Bar Controller作为主屏幕构建并运行。如果超过5个屏幕,它会自动地得到More..。
添加Table View Controller
添加的屏幕都是Tab Bar controller - UIViewController的实例。可以用UITabViewController替换tab screen。点击第一个view controller的边框,删掉。拖一个新的Table View Controller到画布上。
然后,用Navigation controller替换Tab View Controller。选中Tab View Controller,在菜单中选择EditorEmbed In Navigation Controller。这会添加一个controller到画布上。
也可以从对象控制器中拖一个Navigator controller过来。
Prototype Cells可以轻松设计tab view cell的布局。
选择cell,在Attributes inspector中设置style为subtitle。
GCD
代码和智能提示(自定义MainViewController)
参考资料
OC-Tab Bar-iOS开发UI篇—UITabBarController简单介绍
Swift - 标签条(UITabBar)标签页控制器(UITabBarController)用法
iOS From Scratch With Swift: Exploring Tab Bar Controller
一篇较为详细的 Storyboard使用方法 总结
参考资料
Swift - 修改顶部状态栏(statusBar)文字颜色为白色 StoryBoard
View Controller在Storyboard上叫“scene”,scene表示view controller在storyboard上。
一个单一的view controller包含一个空视图。
应用程序如何加载?
打开AppDelegate.swift
AppDelegate类的@UIApplicationMain属性是模块的入口。如果使用storyboard,应用程序从UIResponder继承一个UIWindow属性。所有的方法都是空的。application(_:didFinishLaunchingWithOptions:)也返回true。
info.plist
Swift4
错误问题
Declarations in extensions cannot override yet error
解决方法 参考资料
Declarations in extensions cannot override yet error in Swift 4
Limiting @objc inference
[swift-evolution] [Proposal draft] Limiting @objc inference
The Swift Programming Language (Swift 4) - Extensions
Swift4
错误问题
Initializer does not override a designated initializer from its superclass
解决方法 参考资料
从 Swift 初始化说起
正确编写Designated Initializer的几个原则
Initializer does not override a designated initializer from its superclass
Apple官网- UIButton
Swift - 按钮(UIButton)的用法
Swift,UIButton,addTarget
Swift - 按钮(UIButton)的用法
UIButton常用属性和函数详解