I'm trying to add 3 UItableviews to a viewcontroller view using IB and adding auto layout constraints to achieve the following conditions:
space between tableviews and borders = 20
space between tableviews = 20
Equal tableviews widths
when I run the app on the simulator, I get a strange behavior. The tableviews seem to be positioned correctly, behave as expected during rotations, but the content of one of them is always shifted down...
it looks like a space above the header that I can't explain and remove...
Any ideas ?
Thx.
H.
Add the top constraint to the first table view and bottom constraint to last tableview in the view controller and in the middle tableview assign top and bottom constraint as vertical spacing between the table views and height as less priority. It may work.
Related
I've created a UIViewController in a storyboard using autolayout and it has an embedded UITableView. For some reason there is white space above the table view section. My expectation is that the tableview would split all available space into cells and have cells starting right from the top.
What is causing the table view to add empty space above the first section when using auto layout and size classes?
(See screenshot below, the white space beneath "television" and above "Prototype cells" is the problem)
I've examined the constraints and insets, and cant see anything wrong with them:
UPDATE:
Here's the scene hierarchy
Try toggling the UIViewController property in Interface Builder named:
Adjust Scroll View Insets
If you drag a view into the table view it becomes the tableviews headerview that gives a space similar to what you see. Could this be the issue? Your posted layout looks correct.
Alternativley If you click on the Watch view controller in the hierarchy and switch in the simulated metrics section the top bar property from inferred to translucent navigation bar and back again this seems to move the cells down in the tableview when it is set to a translucent navigation bar
So I am using interface builder (which I don't often use), and I have two storyboards, one for iPhone 5+ and one for iPhone 4. The iPhone 5 one works perfectly.
However, when I run the app in an iPhone 4 or 4s, one of the UITextViews shrinks in size like it has deflated. When I use constraints, I usually put the views where I want them then do Editor -> Resolve AutoLayout Views or something, and normally the views snap into place.
Here is what it looks like in IB:
IB constraints
And this is what I get when I run the app:
The UITextView when I run the app
This is probably a really simple mistake, but I do feel like a bit of a doompf with my pancake like UITextView. Does anyone know what constraints I could add/actions I could take in order to make the UITextView the size it is in the storyboard?
I am in Xcode 6 and I am using auto layout.
Thanks in advance,
Edit Solved:
Firstly, I deleted the 3.5 inch storyboard so I only have one storyboard.
Then I selected the view in question, and fiddled around with the different iPhone sizes. Once I had put constraints that look good on all the devices, I ran it on every phone, and it worked :).
I agree with #Minestroni-Soup that you don't necessarily need to use two distinct storyboards. In any case, here's how I'd approach the problem. First, I'll ignore the horizontal direction because your problem happens in the vertical direction. If you have problems with the horizontal direction, post a new question.
Place constraints of fixed heights between vertically adjacent views in your layout, and also between the top view and the top border, and also between the bottom view and the bottom border. Then create a constraint that sets the height of one UITextView to be the same as the height of the other UITextView. That should solve your problem.
top border
constraint to set a vertical space of some amount
label 1
constraint to set a vertical space of some amount
textview 1
constraint to set a vertical space of some amount
label 2
constraint to set a vertical space of some amount
textview 1
constraint to set a vertical space of some amount
bottom border
Note that the above, alone, doesn't uniquely define the heights of the two text views but if you add a constraint that sets their heights to be the same, then all the constraints together will have a unique solution (because the labels have well-defined default heights).
I hope my explanation is clear enough.
I am new to IOS, I want three table views in one view controller. when I scroll in horizontal it will move to table 2 and table 3. please help me in coding. how doing it.
Put horizontal scroll view with content offset width equal to 3 tables width then add uitableviews to that scroll view with proper x origin. Obviously it would be better to use NSLayoutConstraints for that, but the first way is o.k. for you I guess.
I have a UIView and a UITableView. I'm trying to align them in a way so they are sticked to each other. The UIView has a fixed height and I want the UITableView to consume the rest of the horizontal space.
I applied a set of constraints which got me pretty close to what I want to achieve but there's a problem that I don't know how to solve. The layout is OK in the portrait orientation but there's a gap between the two elements in the landscape mode. Please see the screenshots below.
Here are the constraint setups for the elements.
UITableView: (all constants are set to 0)
UIView: (all constants are set to 0 except for Height)
Thanks in advance.
I had the same issue of that space appearing above the top cell of a UITableView.
Like yourself, I looked into the constraints and the properties of the table, though the only way I could fix the issue was to delete the UITableView altogether and re-insert it.
Once re-inserted the gap was gone.
I am trying to stick a UIView, containing an ADBannerView, to the bottom of my UICollectionView that works in both 3.5 and 4". My current implementation works for 4" but it gets cut off in 3.5".
3.5"
4"
Storyboard
Constraints
My constraints are essentially setup as: height = 50, space to the left, right and bottom of the screen = 0. As a test, I tried the same constraints on a separate UIViewController and it works as expected. The same constraints doesn't seem to be working in an UICollectionView.
Assuming your collectionView has leading/trailing/top/bottom constraints of 0 to its superview, which will ensure that the collectionView always occupies and is contained by the full screen.
You can then add leading/trailing/bottom constraints of 0 and height of 50 to the bannerView with respect to its superview (the collectionView). And because the collectionView will be constrained to always be fullscreen, without bleeding off, you know that the bannerView will always occupy the bottom 50 pixels of the screen too.
OR
You can add leading/trailing/bottom constraints of 0 and height of 50 to the bannerView with respect to its superview (the viewController (NOT the collectionView)) so that it really has nothing to do with the collectionView, instead it's just pinned to the bottom of the encompassing view.
Two approaches that should yield the same result.
Hope this helps!
Update
Adding an observation from my comment below:
I also now am noticing that your bannerView is a subview of a cell. This is probably not what you intend, right? (ie you dont want a banner for every cell). It should probably be a subview of the collectionView, or better yet the encompassing UIViewController...