user3210784 user3210784 - 1 year ago 109
Swift Question

Fail to hide empty cells in UITableView Swift

I'm using UITableView in a swift application, and using my own custom UITableViewCell.

When trying to hide the empty cells in the UITableView, its still have the white background.

Under the UITableView I have a background image (UImageView).

I'v already try to hide those cells, and actually they are hidden, but I still have a white background, using this code:

override func viewDidLoad() {
var tblView = UIView(frame: CGRect(x: 0,y: 0,width: 0,height: 0))
tblView.backgroundColor = UIColor.clearColor()
tableView.tableFooterView = tblView

var nipName=UINib(nibName: "CustomCell", bundle:nil)
self.tableView.registerNib(nipName, forCellReuseIdentifier: "CustomCell")

Answer Source

Here Is the solution:

var tblView =  UIView(frame: CGRectZero)
tableView.tableFooterView = tblView
tableView.tableFooterView.hidden = true
tableView.backgroundColor = UIColor.clearColor()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download