Reputation: 1964
I have a UITableView whose frame is set to the parent view's frame size. The table view appears just fine on an iPhone. However, on an iPad, it has this thick margin on both sides.
If I select the cell, it shows that the table does indeed span the whole width. However, the separators seem to be smaller. I have tried setting the layoutMargins to zero, but it has no effect. Here is how I add it to my view:
self.optionsView = UITableView()
self.optionsView.delegate = self
self.optionsView.dataSource = self
self.optionsView.hidden = true
self.optionsView.frame.origin = CGPoint(x: view.frame.size.width + 30, y: 0)
self.optionsView.frame.size = view.frame.size
self.optionsView.layer.shadowColor = Palette.shadowColor.CGColor
self.optionsView.layer.shadowRadius = 10.0
self.optionsView.layer.shadowOpacity = 0.3
self.optionsView.clipsToBounds = false
view.addSubview(optionsView)
Any idea what's going wrong here?
Upvotes: 2
Views: 902
Reputation: 12549
here it is:
tableView.cellLayoutMarginsFollowReadableWidth = false
From Apple Docs:
CellLayoutMarginsFollowReadableWidth:
A Boolean value that indicates whether the cell margins are derived from the width of the readable content guide.
What is the Readable Content Guide:
A layout guide representing an area with a readable width within the view.
Discussion:
This layout guide defines an area that can easily be read without forcing users to move their head to track the lines. The readable content area follows the following rules:
The readable content guide never extends beyond the view’s layout margin guide.
The readable content guide is vertically centered inside the layout margin guide.
The readable content guide’s width is equal to or less than the readable width defined for the current dynamic text size.
Use the readable content guide to lay out a single column of text. If you are laying out multiple columns, you can use the guide’s width to determine the optimal width for your columns.
Conclusion:
Apple decided that you would be using by default their dynamic text engine and only 1 column on your table views. If you are not in this scenario, you should probably turn off this property. If you want to know the value for the readable width you can get it like this:
tableView.readableContentGuide.layoutFrame.width
Upvotes: 5
Reputation: 230
Keep a break point on this line
self.optionsView.frame.size = view.frame.size
and check what is the frame size for view
.You will be able to understand more after that.
Upvotes: 0