I need to add a registration so that the space between each cell in each section is fast 2.1
but all I managed to do was add a title for the section that I don't need.
How can I add space between dynamic table cells?
Here is the code to add the header:
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 10
}
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView()
header.backgroundColor = UIColor.clearColor()
return header
}
This creates the table view code:
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tableData.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
let rowData = self.tableData[indexPath.row]
cell.textLabel!.text = rowData.name
cell.textLabel!.textAlignment = .Right
if let url = NSURL(string: rowData.img),
data = NSData(contentsOfURL: url)
{
cell.imageView?.image = UIImage(data: data)
}
return cell
}
Right now, my view of the table is as follows:

update code and table view:

source
share