In your method numberOfRowsInSection :
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if data.count > 0 { return data.count } else{ let image = UIImage(named: "Nature") let noDataImage = UIImageView(image: image) noDataImage.frame = CGRect(x: 0, y: 0, width: tableView.bounds.width, height: tableView.frame.height) tableView.backgroundView = noDataImage tableView.separatorStyle = .none return 0 } }
numberOfSections must be greater than 0
source share