承接昨天的内容,今天来开工啦
这篇的资源参考与上一周同样教学团队的real-time开发影片
Swift 5: Firebase Chat App (Real-Time - 2020)
後来发现Real-time影片会比较零碎,可能的话我尽量把相同区块的程序放在一起。
点选专案,General这边可以设定一些资讯
由於这个app只会有一个方向,故可以把landscape的设定都取消打勾。
接着再到Info.plist将多余的item删除
昨天在新增view controller的时候,只有简单带到新增档案,没有提到要选择cocoa touch class
。简单来说,Cocoa touch已经将我们所需的架构提供好,我们在既有的framework下进行开发会更快速方便。
Cocoa Touch is a UI Framework used for building software programs to run on iOS. You can think of it as a swift file that comes "ready made" with a few things for you to use. For example, the UITableViewController Cocoa Touch object comes pre-filled with methods necessary to make the table view work. UICollectionViewController is another example.
A swift file is just that - an empty swift file. There is nothing pre-populated inside of it. Empty swift files are typically used for custom classes, structs, enums, etc. Once you start building more applications the difference will become apparent.
如果当前直接执行程序,会进入conversationViewController的画面中,因为我们把预设viewController改名字成conversationViewController,所以也需在storyboard修改所连结到的class名称!
总之,改好後执行没有问题,不过显示起来就是空白画面,因此我们加上个背景色然後执行。
import UIKit
class LoginViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
import UIKit
class ConversationViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let isLoggedIn = UserDefaults.standard.bool(forKey: "logged_in")
if !isLoggedIn {
let vc = LoginViewController()
let nav = UINavigationController(rootViewController: vc)
nav.modalPresentationStyle = .fullScreen // if not-> pop up as a card
present(nav, animated: true)
}
}
}
到这边就可以执行程序,成功的画面可以看到红色的背景!
最近突然很忙,因此文章比较短QQ。
明天开始实作注册的画面,好期待R!
what is the difference between a cocoa toach file and a swift file ?
若上述内容有误或可以改进的部分,欢迎留言以及提出任何指教~
谢谢ヽ(✿゚▽゚)ノ
>>: ASP.NET MVC 从入门到放弃(Day21)-MVC查询资料介绍
此文由 Nutanix 首席技术营销工程师 Dwayne Lessner 撰写 Nutanix/X...
今天要谈到代理模式,其实跟昨天的装饰器模式很类似。代理模式的目的在於,因应某些条件替换物件原本的行为...
如果你有专案,有作品,通常一定会问你这类题目,而且你的回答很重要,千万要小心作答! 以我自身的例子...
今天我们要来学习如何把Sass切分支许多档案 这样会使我们比较容易管理 @import(汇入) 可将...
今天介绍的是避免重新渲染的 HOC(Higher Order Component) React.me...