Show no data in table view - when no data return from api

后端 未结 1 1305
一向
一向 2021-01-22 12:11

I have some 15 collection view cell.when user click each cell, that respective cell data will display in next screen table view.But , some cell are don\'t have any data.In that

相关标签:
1条回答
  • 2021-01-22 12:24

    Try this:

    func numberOfSectionsInTableView(tableView: UITableView) -> Int 
    {
    
            var numOfSection: NSInteger = 0
    
            if YourArraydata.count > 0 
             {
    
                self.tableView.backgroundView = nil
                numOfSection = 1
    
    
             } 
             else
             {
    
                var noDataLabel: UILabel = UILabel(frame: CGRectMake(0, 0, self.tableView.bounds.size.width, self.tableView.bounds.size.height))
                noDataLabel.text = "No Data Available"
                noDataLabel.textColor = UIColor(red: 22.0/255.0, green: 106.0/255.0, blue: 176.0/255.0, alpha: 1.0)
                noDataLabel.textAlignment = NSTextAlignment.Center
                self.tableView.backgroundView = noDataLabel
    
              }
    
            return numOfSection
      }
    

    0 讨论(0)
提交回复
热议问题