UITableView height problems in Retina 3.5-inch - uitableview

If you look at the screenshot, showing a list of US states, "WV" is not the last row, there are two more rows after: "WI" and "WY" which extend beyond the bottom of the layout. This used to work with Xcode4/iOS6 regardless of whether or not you were in 3.5-inch or 4-inch. Now this only seems to work for 4-inch but not 3.5-inch.
Does anyone know how to get the height behaving correctly for Retina 3.5-inch?
The orange background in the storyboard screenshot below is the View background color.

You need to use the buttons in the lower right-hand side of the interface builder. Specifically, you can use the "Pin" button to create constraints to the top/bottom and other gui objects.
Constraints in Xcode4 used to auto-create if you dragged an object to the edge of the screen but not anymore in Xcode5 which is why I was confused.

Related

constraints doesnt keep it in the middle

When I add an image and constraint it to remain in the top-half center of the screen; I would like it to work with all iPhones except it doesnt,.the problem is it only works with iPhone 4 portrait and landscape that I have but when I change the iPhone to iPhone 6 it doest stay in the middle, does anyone know why?
To geta an element in the middle of the screen here are a few tips:
Ensure you drag the object in to the middle of the screen (Horizontally). You will notice guideline's appear up the screen.
Set the constraints on the item which include 'Set Horizontally in container' & Set a top constraint only (You may want a height wand width also, experiment with this.
For an image make sure that you have set your fill property for your application. (Aspect Fill etc)
A good tip to get used to auto layout is to set your view controller to iPhone 4 and design on that (With constraints of course)
Auto-Constraints are rubbish, create them yourself!

xCode auto-layout different on 5 and 5s

I have a calculator display in my app that uses auto layout. The iPhone 5 and iPhone 5s have the same display and resolution; however, when I run the app in the simulator the iPhone 5 displays it far poorer than the iPhone 5s. Why is this, and how can I fix it?
Since I cannot see your constraints it is difficult for me to give you a definite answer. This is what I would do.
select the text field that is mis aligned
click on the far left triangle between two pikes icon.
click on clear constraints.
a. rest to suggested constraints -or-
b. control drag to the sides and create your own constraints
According to this link https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TransitionGuide/AppearanceCustomization.html
To adjust how a view controller lays out its views, UIViewController
provides the following properties:
edgesForExtendedLayout: The edgesForExtendedLayout property uses the
UIRectEdge type, which specifies each of a rectangle’s four edges, in
addition to specifying none and all. Use edgesForExtendedLayout to
specify which edges of a view should be extended, regardless of bar
translucency. By default, the value of this property is UIRectEdgeAll.
Try to set self.edgesForExtendedLayout=UIRectEdgeNone;

Xcode 6 Do I have to make an application for every screen size?

So I have created my webapplication and when I build it in xcode I have to under "Simulated Metrics" > "Size" set it to 3.5 inch since I have a iPhone 4s.
When I build it and run on the iPhone everything looks perfect, but I want this application to run on iPhone 5/6 aswell, but when I change the size to something else in the Simulated Metrics it gets really messed up on my iPhone. I'm using a webview of my responsive website which shouldn't really care about the screensize but I believe Xcode does. So, is there a solution where xcode automatically detects screensize and makes the webview take the whole viewcontroller? Or do I have to create a application for every screensize?
So, is there a solution where xcode automatically detects screensize
and makes the webview take the whole viewcontroller?
Yes - xcode provides ways to do this. Either through auto layout or using springs and struts. With auto layout you will define a set of rules that your UI will follow. If you want 1 layout for all devices it's fairly straightforward and any tutorial will get you started. with springs and struts you just tell your views how they should grow/stay put depending on screen growing. check this out for a quick introduction to auto layout: http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1
Or do I have to create a application for every screensize?
Nope.. but you can set different constraints in auto layout for your views to behave very different on different sizes. This gets a little more tricky..
No you do not make a new app for every potential screen size, instead you uses XCode's "auto layout" with a set of "constraints" controlling the size and placement of your widgets. A constraint can be a fixed size for the widget or a given distance relative to another widget (or the parent's border). It is not necessarily a fixed distance, it can also be "my widget needs to be less than 10 pixels apart from this other widget".
The "Simulated Metrics" you refer to in the bottom of the drawing area is only a visual help when laying out you your GUI, it has no effect at runtime. You can safely stick with "Any" width and height.
Read this tutorial to understand XCode's auto layout and constraints:
http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1
Quickly, these are the tools used to setup constraints:
In your case, assuming you have only one big view (your webview), you need to set up 4 constraints stating that the webview's left, right, top and bottom sides are 0 pixels away from the parent's left, right, top and bottom borders respectively:
Lay your webview in the middle of your drawing area
Click on it
Click the "pin" button; you will see this view:
Look at the upper part of the dialog: the small square in the middle represents the view you just clicked and the four red lines represent the distances to the parent's side. Set them all to 0 and click "Add 4 constraints". (Note: the lines are initially dashed when not selected; they turn into solid lines when activated.)
Now the frames in the drawing area do not represent what you were expecting: your webview is still in the middle where you placed it initially and does not fill all the available space; XCode is aware that there is a mismatch between the frames and the constraints and shows a warning. You need to update the frames: click the "issues" button and "update all frames".
The image comes from this question on SO:
What is "Constrain to margin" in Storyboard in Xcode 6
Read it to learn about the "Constraints to margin" switch.

Xcode - Adding constraints to UITableView so that it fits all screen sizes

I've read quite a few tutorials and watched numerous videos on using constraints in Xcode. For some reason, I'm still missing certain aspects that are necessary to make the user interface look the way it's supposed to for all screen sizes.
Currently, I have a UITableView laying on a view controller. The view controller is set to "Inferred" size and I have all of the different sized devices open in Assistant Editor Preview to the right so I can view the changes. I've encountered multiple problems attempting to get the constraints correct for the different screen sizes.
Problem 1: The UITableView has a width set to 600. This causes dead space to the right of the table view on the iPad preview and it causes the UITableView to extend too far on the smaller devices. If I make the width of the table view smaller so that it fits within the preview of all screen sizes and then pin the left and right edges of the table view to the edge of the Superview by specifying 0 and unchecking constrain to margins, the result I'm seeing in preview is that the entire table view disappears completely from each device size. I was surprised by this because I thought by pinning the table view to the margins, it would make the table view fit within each of the screens.
Problem 2: (This is a completely different scenario from Problem 1, above.) In this situation, I've left the size of the table view to 600 and just specified constraints for the internal components of the cell contained within the tableview. In this case, the table view is still slightly not wide enough for the iPad dimensions and it extends too far on the smaller devices which makes components in the cells to be truncated and off of center.
I've primarily been working in Storyboard with Any width, Any height set. However, if I change the setting to Compact width, Any height, I can alter the constraints to fit the smaller devices a little better, but there's still a problem with getting things to work between the 5.5 inch screen and the smaller devices.
I would like to get my UITableView to extend all the way to the edges on each device and I would like to have the view inside of the cell remain centered and keep it's relative size on each of the devices. Does anyone have any suggestions on how I can accomplish this?
if you want to make your tableview to "fill" the whole screen (device-independent) the only thing you have to do is to pin its 4 edges (top, left, bottom, right) to its superview (the viewcontrollers view in your case) with a constant of 0.
you do not specify a specific width (like in your case 600) or height.
good luck :)

Change Text Alignment in UITableViewCell On Rotate

I am using sizing classes to turn two xib files (iPhone vs iPad) into one. Most orientations have a 2x2 grid of UILabels above a UITextView. However, for iPhone portrait, I want the UILabels to stack vertically. I have this working great with sizing classes. I was disappointed to see, however, that sizing classes don't allow for the change of text alignment. Refer to my diagrams below. In the main orientation I have the text in the yellow and blue UILabels right-aligned. In the iPhone portrait orientation I want the same UILabels to have left-aligned text. How can I change this if the user rotates the device while viewing these table cells? I figure there's a better way of doing this than reloading the table.
I dont think it is possible to setup the text alignment based on the screen orientation or device. however you can create 2 labels, one with left aligned text and the other with whatever you're using otherwise, in a way that they are exclusive to the screen layout you're using. I.e. one label for iPhone and one label for everything else.
You can select then, for that UILabel object in storyboard, which screen layouts it will be installed for.

Resources