Segue不断重新加载屏幕



我是编码新手,最近几周一直在构建一个应用程序。我有点卡住了,不知道从哪里开始寻找。我有一个应用程序,可以在用户之间发送消息,具有社交媒体页面,并在应用程序中显示所有用户。我有一个附加选项卡,我想授予 2 个用户的管理员权限。其他用户有权访问同一选项卡,但看到的内容不同。

我有一个如下所示的 json 树:

users 
| 
| 
| 
Jjhi848hjnef8 
| 
| 
| 
name: 
email: 
profileImageUrl: 
ETC: 

我还有一个消息树,以及用户消息树。我不想与用户一起创建新的 json 树,然后设置角色的子类别,因为我希望所有用户都能够相互发送消息并访问除选项卡式应用程序中的一个视图控制器之外的相同内容。有没有办法干净/有效地完成此操作,这样我就不必重新编码消息、配置文件和所有用户选项卡?

这是我尝试运行的代码:

import UIKit
import Firebase
class ToDoViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
checkIfAdmin()
}
func checkIfAdmin() {
Database.database().reference().child("users").child(Auth.auth().currentUser!.uid).child("userType").observeSingleEvent(of: .value, with: {
(snapshot) in
switch snapshot.value as! String {
// If our user is admin...
case "Admin":
// ...redirect to the admin page
guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "AdminVC") else { return }
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true)
// If out user is a regular user...
case "Talent":
// ...redirect to the talent page
guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "TalentVC") else { return }
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true)
// If the type wasn't found...
default:
// ...print an error
print("Error: Couldn't find type for user")
}
})
}
}

我的用户类型节点的值为"管理员"或"人才"。我正在尝试让标记为管理员的用户在我的选项卡控制器中看到特定的视图控制器。我现在可以看到不同的页面,但我遇到了一个小故障,它以模式显示视图控制器,并且它会不断重新加载页面并且不会停止移动。如果我将动画转换为 false,它会卡住并且不允许任何交互性。

仅通过查看此代码片段很难说出为什么会发生这种情况。 我认为您还应该上传TalentVC视图控制器的代码

最新更新