UITableview blocking uiview - ios

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.

Related

Xcode Interface Builder Pin Tool makes UITableView disappear

I have a UITableView and I want it to hit the upper bar, the sides of the view and the Seek Bar below. When I add constraints with the Pin Tool, the UITableView simply disappears and I get no log output.
I use the Pin Tool like shown here:
After this, the table disappears. Why? Here is another picture of my setup, it's literally just up/down/left/right constraints, nothing else, what am I doing wrong?
Solved it by giving the top bar some constraints and giving the UITableView a "width" constraint - I have no idea why that works but now it scales nicely for every display size

Fitting a tableView into its parent UIViewController

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.

Adding Spacing Constraints to Text Field

I have a simple storyboard with a text field. I want to add spacing constraints to this text field so that, when I rotate the device, the text field will auto stretch across the screen instead of stopping halfway.
I have looked at multiple tutorials and they all say to "Control-drag from the text field toward the top of the scene, ending in the empty space around the text field. This should reveal a pop-up menu from which you can edit the spacing constrains of the text field."
However, when I control-drag from the text field, I get this different pop-up menu:
This other pop-menu clearly does not allow me to do anything with spacing constraints. In fact, I can't click on it at all.
Furthermore, clicking "Editor > Resolve Auto Layout Issues" does not work, as the entire sub-menu is grayed out.
How can I correctly add a spacing constraint to this text field so that when I rotate the device the text field will correctly fill up the screen? Please try to refrain from answers that involve editing code, as I don't actually know any Objective-C and would like to make this effect in the storyboard.
NB - If it is at all helpful, I am following this tutorial. Albeit it is with Xcode 5, other tutorials on Xcode 6 suggest the same pop-up menu should exist.
You probably didn't activate auto-layout in the first place. Check the option in the right panel, under the File section:
It's a new behavior of IB
For example:
Now the contents of the menu depend on the edge of where you are trying to tie constraint:
or simple use tree from left of IB
Open the document outline to see the view hierarchy and try control dragging the text field to the View, it should show the options there. Your menu appears when you control drag onto the View Controller.

UIViewController with UITableView and TextField storyboard placement

This might be a simple question but using storyboard I can't seem to position my table, a message field and a button correctly. In the picture below, if it's positioned that way, only then do I get to see the text field and button at the bottom of the screen and the table view takes up the rest of the screen. If I drag the text field and button to the bottom and resize the table, the text field and button disappear and the table is cut off. Why is that? Is there a solution to this without doing it programmatically?
Easy solution is to remove all constraints then position them where you want them.
You'll find you get different effect when try to reposition items depending where you drag from for example double tap an item and nudge it with arrow keys or grab the middle to move it resizing via the corners.
But in my opinion it's easier remove all constraints from the view and then set them as you go.
Also you might want to consider using a container view for the table view and have a separate UItableViewController that way you can easily separate out that the tableview logic from the other ViewController. It will help stop things getting a little messy later on as project grows.

ViewController gets misplaced, when a view size is adjusted

I'm quite new to the Xcode programming. I've added some view controller, labels, buttons and image view to my program, but, when I try to adjust, for example, the size of a label, the view controller that that label is in, gets displaced. I mean, when I try to drag the side of the label to change its size, the view controller moves down, making my label get displaced in the view controller. It is a very weird situation, here you have the screenshot of my project, the view controller misplaced is the one that says "Perfil" on the navigation bar. Every time I try to change one of those light blue views size, the entire view controller changes place. The more I try to change the side the more it will go down.
Sorry for my English, not my native language.
I think the bigger issue is that you are using Table View Cells that are not part of a table view.
Table ViewCells are supposed to be a part of a UITableView and not just stuck in a view.
Using UITableViewCells in this way is what is causing the strange behavior.
If you are trying to make a table, put a UITableView in your view, and then you can customize the table view cells in there.
It you aren't trying to make a table, just use UIView's instead of those UITableViewCells.
I have two ideas that may fix the problem:
First, if you're trying to drag and drop the label but the view controller moves instead, then you might just be grabbing the view controller's background by mistake. When this happened to me, it was because the order of my components in the xib file was wrong. Things are ordered from back to front, and when you click and drag something, you'll just be clicking and dragging whatever's on top. You can try and get past this by clicking the UI element on the left to be sure you select it, then dragging the handles.
It looks like you have things in a reasonable order, so that may not be the culprit at all.
Second, if that doesn't work, select the element you want to edit on the left, then open up the utilities pane on the right. Click the Attributes icon (should be fourth from the left) and look towards the bottom. You should see something like this:
Just manually edit the position and size of your labels there. You should see the change immediately reflected in the display.
Hope this helps!
Setting no autoresize behavior in Interface Builder solves the issue.

Resources