Fitting a tableView into its parent UIViewController - ios

I dropped a TableView into my ViewController using Storyboard and I want it to be filled without any margins like the lower ViewController with TableView in the image below.
I tried some suggestions from the answers in other similar questions but didn't work at all.
Some say I need to set PIN. and I tried it like below:
I've typed '0' for all 4 constraints but this is what I got:
This AutoLayout thing makes me really hard to layout things automatically, unlike it's name.
What should I do now?

Just Click on Resolve Auto layout Issues after that click on Update frames as shown into below image.

In the Document Outline, tap the yellow arrow:
Tap the yellow triangle:
Then select Update Frames, Fix Misplacement.
This will fix the misplaced view. Alternatively you could have resized the table view before specifying the constraints.
I recommend you have a look at an auto layout tutorial, for example link.

Related

IOS UITableView right half cut off screen

For some reason, no matter what I do, when I create a static tableview inside a UITableViewController, put content into the cells and run the simulator the right half of the screen is always cut off and I don't know why. Ive tried making new projects and remaking the storyboard but nothings working.
Here's what it looks like when I run the app
heres what the storyboard looks like.
I have content set to static cells
Anyone run into this problem or know how to fix it via storyboard (or programmatically but not preferred)?
Update:
Here are some more pictures of what another project looks like when I run it:
and here's what the storyboard looks like
You need to give constraints to your right button...
For that select your button and pin its edges to right, top, bottom and give width constraint like below
and here is autolayout tutorial link .. you can check that
I see the problem in giving constraints to the table not for the button.
Try giving constraints to the table like "leading space to superview,trailing space to superview,top space and bottom space to superview
Edit:
The above solution given by me might fix for tableview inside UIViewcontroller.

Extra space on top and bottom of Init View Controller

I have a swift app I have been working on for some time now. I noticed that my init view controller has extra space at the top and the bottom of the view, so much that it allows me to pull up and down on the first view and let go and have it spring back into where it was. I removed all my constraints thinking I had an issue with them, but it's still done the same thing. The size class is set to any any, and all my graphic fit inside the view, yet I still an able to pull up and down.
I also made sure my view, wasn't a scroll view, it's not.
I looked around for similar issues, but couldn't find anything like this.
Thanks for the help!
Here is what my view looks like in IB
When I run the app.
Showing the amount I am able to pull it down from the top.
If you remove all of your constraints, and the storyboard is set to use auto layout, it usually won't show up correctly, as you have seen. You will have to add the constraints to each element in your view controller. To do that, you can control click on each and drag it where you want to connect a constraint. Or, use the pin and align buttons in the bottom right corner of the storyboard view.
There is a good tutorial from apple that I suggest you read. It will help you with the basics of using auto layout. Another option would be to not use auto layout. To turn it off in the Storyboard, go to the file inspector and uncheck the box "Use Auto Layout".

Update constraints menu all greyed out

When I try to update constraints in Xcode 6.3, I can't because the menu is completely or partially greyed out.
http://hostthenpost.com/uploads/aa150beda71316c338da81c5e301d149.png
Why is this? How do I fix it? The app is a basic, simple Hello World app with two UIImageView elements both sharing heights and widths, and one is constrained 50 from the left, the other 50 from the right. What is wrong with it? How to I make it so I can update the constraints?
Edit: This is when I can see some, but not all of the constraints options.
http://hostthenpost.com/uploads/2d8a3bec6a17524d6f9ca1524c95fb0c.png
That happens when you have a wrong item selected, meaning for example a constraint instead of the view or a subview.
To fix it, just select the view again. Then the options should show up again.
Still some options will be grayed out, if they would have no effect when clicked. For example Update Frames will only be available if there are actually are frames to be updated.
If you clicked on the main view and then on the constraints button, you have to know that you can't adding constraints from the main view in the storyboard, to its superview. You can do this just by code.
If you are trying to change the constraints for any other subviews, please be sure to click with the mouse on the object in the view, and then on the constraints button.

Detail Text and Accessory Don't show [duplicate]

I'm trying to use Auto Layout for a custom Table View Cell in my app.
I can't seem to get the constraints quite right.
I layed the labels out in the custom Table View Cell, but the labels are still getting cut off. Any ideas?
Thanks! Will post anything else needed. Tried to show needed info in picture below:
Debugging in Xcode. Somehow what shows in Simulator looks different than in Xcode debug.
Here's the width of my TableView shown:
UPDATE:
The problem here was related to what user matt said in the accepted answer, but I wanted to make the Q&A a bit clearer now that I have it figured out for anyone else that comes across this.
In his initial comment, he mentioned the Xcode View debugging, which was great and I was able to dig into a little bit more. Its called the Assistant Editor: Device Preview, where you are able to see the layout and layers of what is onscreen to see if maybe you have labels overlapping or going offscreen based on the device it is running on. If you want to check multiple device sized, just hit the plus icon in the lower left hand corner of this picture.
This helped me find overlapping layers and sizing issues with the TableView. I was able to see how it looked on each device size.
What also helps here sometimes to use the Pin menu. Sometimes the labels can run off screen because it doesn't know where the constraints of the cell are based on the device size. So your label can run offscreen if the label is based off of a landscape layout but the device is an iPhone 5 and is in Portrait for example. This is the Pin menu:
Hope that makes sense and gives some more color to the problem. Let me know if you have any questions at all, thanks for the help everyone!
The problem is that you are using auto layout but you have not done anything about sizing the table view. The table view here is not your view controller's view; it is a subview. Your view controller's view is automatically sized to the size of the device / window, but its subviews are not automatically resized. So you are ending up with the table view much too wide for the device; the whole table is sticking off into space on the right side.
Use a trailing space from the right side of your labels to the edge of their superview, and set it to greater than instead of equals with a value of ~ 5
Review the constraints of your tableview with the View. Draw cell border, label border and tableview border with different colors to know which elements do not display correctly.
Ex:
#import <QuartzCore/QuartzCore.h>
...
cell.layer.border.width = 1;
cell.layer.border.color = [UIColor blackColor].CGColor;
The thing that worked for me to solve views being clipped was to uncheck "Constrain to margins" in Auto Layout.

UITableview blocking uiview

So I had a UITableView that I tried to make smaller by adjusting its constraints. I then added three labels and textfields to my UIView. However, upon running the app the UITableView doesn't seem to have been made smaller, instead it's "overlapping" my labels and textfields. Here is a picture of what I am describing. http://imgur.com/BoC6l1R. And here is a picture of the storyboard editor. Note the dotted lines. http://imgur.com/wUyccDk. I've tried changing many things with the constraints but they all make everything more messed up. I feel like the solution should be pretty simple. Thanks!
In the second image (the storyboard) you see there's a dotted line and a yellow line with +78. That indicated that the constraint specifies that the table view should be 78 points above where it is now. That's a warning in your storyboard meaning that the UITableView will appear in a different position at runtime.
The easiest way to solve it is to open the storyboard file, then at your left there should be the Document Outline. Find your view controller, and there should be a small yellow arrow next to the view controller name. Click on it and you'll go to a screen showing you the constraint warnings. It should say "Misplaced views". Click on the small yellow arrow next to the misplaced view (your UITableView) and a popup will appear. Select "Update Constraints" and then click on "Fix misplacement". That should do it.
However, a better way to solve it is to put a constraint between your text fields and the UITableView. Delete the constraint between the table view and the top layout guide (the one appearing yellow), then add a Vertical Spacing constraint between the UITableView and the UITextField below the Sea_State label.

Resources