选择标签栏时黑屏

Black screen when tab bar is selected

当我切换到应用程序中的 "friends" 选项卡时出现黑屏问题。这确实是因为我的朋友viewcontroller。我知道这一点,因为我将 link 移到了 viewcontroller,它向我显示了正常屏幕。希望有人能看到我做错了什么

FriendsViewController:

import UIKit
import FBSDKLoginKit


class FriendsViewController: UITabBarController, UITableViewDelegate,UITableViewDataSource{



@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var friendTypeSwitch: UISegmentedControl!

@IBOutlet weak var friendSearchBar: UITextField!
var user:User = User()

override func viewDidLoad() {
    super.viewDidLoad()

    print("Friends tab")
    // Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
    print("view did appear")
}






func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 30
}
//What to do with tableview
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCell(withIdentifier: "friendCell", for: indexPath) as! friendsCustomCell
    user.username = "kulgut123"

    cell.friendName.text = user.username



            return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}



}

class friendsCustomCell: UITableViewCell{

@IBOutlet weak var friendImg: UIImageView!

@IBOutlet weak var friendName: UILabel!

}

正如 ronatory 所建议的,您应该从 UIViewController 而不是 UITabBarController 继承 FriendsViewController。

class FriendsViewController: UIViewController, UITableViewDelegate,UITableViewDataSource {
      //type your code here
}