So I have a UITableView with a custom cell...
Here is the cell:
And here is the xib with a UITableView:
I cannot explain the white margins on either side of the blue cells???
I tried:
override func viewDidLoad() {
super.viewDidLoad()
...
table.layoutMargins = UIEdgeInsetsZero
table.separatorInset = UIEdgeInsetsZero
}
I even tried the advice from iOS 8 UITableView separator inset 0 not working:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:Cell_Jobs = self.table.dequeueReusableCellWithIdentifier("Cell_Jobs") as Cell_Jobs
cell.area.text = "Hello"
// kill insets for iOS 8
let nf = NSNumberFormatter()
let version = nf.numberFromString(UIDevice.currentDevice().systemVersion)
if(version?.floatValue >= 8){
cell.preservesSuperviewLayoutMargins = false
cell.layoutMargins = UIEdgeInsetsZero
}
// iOS 7 and later
if(cell.respondsToSelector("setSeparatorInset:") ) {
cell.separatorInset = UIEdgeInsetsZero
}
return cell
}
But I still can't get the left and right margins to go away...
What am I doing wrong?
XCode6.1.1. Building for iOS 8.
And here is the troublesome output with the unwanted margins:
Update for @Teemu Kurppa:
In viewDidLoad()
, I did:
self.view.backgroundColor = UIColor.yellowColor()
self.table.backgroundColor = UIColor.cyanColor()
In tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)
, I did:
cell.contentView.backgroundColor = UIColor.redColor()
Update 2:
So I got it working
- I deleted the parent UIView
- I created a new UIView
- I re-added the UITableView and UIActivityIndicatorView
I copied and pasted (Apple+C) from an Objective-C xib (that was written over a year ago) into a new Swift xib - I suspect there was some funny settings lingering about that were causing these unexplained margins.
Thanks for the help guys,