簡體   English   中英

為什么表視圖不顯示任何內容?

[英]Why is the table view not displaying anything?

我有一個正確設置的表格視圖,但是什么也沒有顯示。 將填充數組,並且所有委托均已正確設置。 我該如何解決? 在此處輸入圖片說明 在此處輸入圖片說明

 override func viewDidLoad() {
    super.viewDidLoad()
    self.friendstable.rowHeight = 150.0
    friendstable.allowsSelection = false
    self.friendstable.dataSource = self
    self.friendstable.delegate = self
    self.friendstable.registerClass(UITableViewCell.self, forCellReuseIdentifier: "friendcell")
    // Do any additional setup after loading the view.
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return titleofsong.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    //var cell = friendstable.dequeueReusableCellWithIdentifier("friendcell", forIndexPath: indexPath)

    let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "friendcell")

    cell.textLabel?.text = titleofsong[indexPath.row]
    cell.detailTextLabel?.text = artist[indexPath.row]
    cell.textLabel?.font = UIFont(name: "Lombok", size: 22)
    cell.textLabel?.textColor =  UIColorFromRGB("4A90E2")
    cell.detailTextLabel?.font = UIFont(name: "Lombok", size: 16)
    cell.detailTextLabel?.textColor =  UIColor.blackColor()

    cell.textLabel?.numberOfLines = 0;
    cell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping

    cell.backgroundColor = UIColor.clearColor()


    return cell
}
override func viewDidLoad() {
    super.viewDidLoad()
    self.friendstable.rowHeight = 150.0
    friendstable.allowsSelection = false
    self.friendstable.dataSource = self
    self.friendstable.delegate = self
    self.friendstable.registerNib(UINib(nibName:"YOUR_NIB_FILE_NAME", bundle:nil), forCellReuseIdentifier:"friendcell")
    // Do any additional setup after loading the view.
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    var cell : UITableViewCell= tableView.dequeueReusableCellWithIdentifier("friendcell", forIndexPath: indexPath)
    cell.textLabel?.text = titleofsong[indexPath.row]
    cell.detailTextLabel?.text = artist[indexPath.row]
    cell.textLabel?.font = UIFont(name: "Lombok", size: 22)
    cell.textLabel?.textColor =  UIColorFromRGB("4A90E2")
    cell.detailTextLabel?.font = UIFont(name: "Lombok", size: 16)
    cell.detailTextLabel?.textColor =  UIColor.blackColor()
    cell.textLabel?.numberOfLines = 0;
    cell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
    cell.backgroundColor = UIColor.clearColor()
    return cell
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM