In Xcode 6 when I add new UITableViewCell some extra top padding adding automatically. I just found the solution how i can remove this padding programatically. But my question is for which purposes storyboard automatically add this padding?
As you can see on the picture below there is an extra white space between prototype cell and top border of the table that is selected right now.
You should disable "Adjust Scroll View Insets" from IB for that particular UIViewController.
Related
I have in the same view controller two UITableView. Both UITableView cells have an UIImageView, a top UILabel with top and lead constraints, a bottom UILabel with lead and bottom constraint. Cells are set the same for constraints but on the second UITableView cell Xcode gives me a missing constraint warning for y position on bottom UILabel , when it actually has a bottom constraint. If I add a top constraint for the bottom label in the second UITableView cell the warning goes away, but it's not needed for the first UITableView. What am I doing wrong?
As always many thanks.
At Storyboard at this case maybe will be better embed your labels at Stack View? And this will make your Cell more changeable and you should better to maintain it?
I'm adding a UITableView to my UIViewController using Interface Builder. Setting up leading, trailing, top and bottom constraints to my superview margins somehow makes the tableView 8 points wider than my viewController.
Here's the view hierarchy:
The constraints:
ViewController view during runtime using Xcode visual debugger:
TableView during runtime using Xcode visual debugger:
the 8 points seems suspicious and I picture it has something to do with margins, though I'm not able to figure it out.
Why is the tableView wider than my viewController?
Uncheck it before u give constraint
remove old constraints . Click on add new . Uncheck Constrain to margin as shown below
Actually by Default story board adds this (Don't know why , any one else can comment about that).
I have problem with autolayout I do not understand.
I have a UITableView and it contains a simple UITableViewCell. Within this UITableViewCell I got a UIView that serves as a background with alpah 0.61.
This is the structure in my storyboard:
And this is my design in the storyboard:
As you can probably see, I set the layout constraints that the UIView object exaclty as wide as the cell itself and also snaps to the bottom. So no margin should be remain.
Now, this is the final result:
So, what is going on and where does this margin come from?
Note: I'm using XCode 6.4.
When you add new constraints in storyboard just disable:
Constraints to margins
(as default, when you add a class extending UIView, using storyboard, margin are enabled)
How to remove the default padding of content view in UITableViewCell?
I put two label in the UITableViewCell's content view, The content view has a gray background color.
when I set top margin space between title and the content view to 0 (via constraint), the title is not align to the top!!! The same is leading and trailing space.
Here is my view struct:
I googled a lot, the answer in this post works by overriding the layoutSubviews of UITableViewCell and setting frame of title manually.
But can I do it in story board? or it there a attribute or something that controls the padding of the content view????
There is a checkbox labeled "Constrain to margins" in the popup where you specify constraints. I suspect you left it checked. Margins default to 8 points, which may explain what you are seeing.
Here is a better answer with screenshots:
https://stackoverflow.com/a/26755511/4122965
I have normal UIViewController on my storyboard with a standard UIView which contains only one child - UITableView
When adding constraints between UIView and UITableView ( equal widths, equla heights, vertical space 0 top layout guide, horizontal space 0 for leading margin ) as a result my table view should fill it's parent.
Instead my table view appears to have left and top margins (16 and 64). The Size Inspector shows that the table views Alignment Rectangle is as follows x=16,y=64,width=600,height=600 although all my constraints have constants set to 0's. When I try to edit manually Alignment Rectangle I keep getting Misplaced Views warnig which try to restore previous values.
Any I idea what might be the cause of this strange behaviour?
Click the view you want to remove margins. Open Contraint Editor uncheck Prefer Margin relative:
I had a very similar problem. It was solved by deselecting Under Top Bars under Extend Edges in the properties of the topmost UIViewController in storyboard.