【发布时间】:2018-07-01 08:20:53
【问题描述】:
我正在尝试使用 Firebase 编写一个函数,该函数允许知道是否使用了用户名。
for username in dict.values {
if username as? String == self.usernameText.text! {
appDelegate.visualReturnBottom(message: "Username already taken.", color: brandBlue, backgroundColor: UIColor.white)
return
}
}
问题是,如果不使用用户名,我想更改视图控制器。为此,我必须等待循环结束,我真的不知道我该怎么做。
我想添加这部分代码“如果循环结束...:”
let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "InscriptionSecondVC") as! Inscription2TableViewController
self.navigationController?.pushViewController(nextVC, animated: true)
【问题讨论】:
-
只需在循环“下方”写两行?
-
补充@Sweeper 的答案;在主队列中编写 UI 更改代码。
标签: ios swift loops firebase swift3