Storyboard preview differs from simulator - ios

I'm currently trying to grapple with constraints (using Xcode 6 GM seed). Using reset to suggested constraints, everything looks right in the universal storyboard and in the preview:
As you can see, I'm previewing for multiple screen sizes. All of them have the image of the dot (and the image itself takes up the whole view, set to draw in the center) in the center. However, when I load it on the simulator, I see:
I'm not sure why this is happening. As far as I can tell, the constraints are all as they should be:
Is there something I am doing? Or is there a bug here in xcode 6?
Thanks in advance!

You don't need to add Leading, trailing, and vertical space constraints. To place your dot in center you need to add Horizontal and Vertical center in container constraint. Place your dot in the center of controller and add these two like in the given image.

The storyboard "Preview" doesn't match the simulator if you have any constraint errors/conflicts. I was having this problem, and found this question while searching for an answer.
One I got all of the conflicts resolved, the Preview worked. It still seems like the preview should consistently show what the simulator would show to help during the setup.

Related

Xcode pin constraints not working

I am brand new to iOS development (I have done some Android and Windows 8/ 10 development), and I am having the hardest time understanding constraints. I have read several online tutorials and am still confused. Currently, I dragged a label into the Storyboard designer and once I positioned it, went to Editor->Pin->Leading Space to Superview and Editor->Pin->Top Space to Superview.
I think that that should work, but it doesn't. Event with the constraints the iPhone 6 simulator displays improperly.
I can't seem to figure this out. Why do my constraints not work?
I am using wAny hAny and even added all pin constraints (top, bottom, leading, trailing).
My best guess is that your Label is too far to the right to be displayed. (You could check its frame in your view controller's -viewDidLayoutSubviews method.)
But in order to make sure that you're writing code that centers the label for all iPhone resolutions, though, you want to use Align > Horizontal Center in Container.
you must have given the constraint value too far. I tried your way , and yes it didnt showed for me too. I better understanding , I am attaching the screenshots too..
as you can see , the value I gave is more than 270 , and this constrtaint is fixed. This is too far from the screen.
Now lets try to give low value to the constraint:

iOS 8 swift application, content not centered

Everytime I run my iOS application, everything is off-centered. In this screenshot, you can see that the text seems a little off, and the black box is definitely not vertically centered along the page, although the text and box are centered according to the storyboard.
simulator screenshot
storyboard screenshot
I am guessing that the issue must have something to do with the size settings on the bottom of the storyboard. I am using wCompact and hAny.
Any help would be appreciated so that all this will look centered properly.
This is probably because you don't have your constraints set. You can click on the UIImage or UILabel and go to Editor -> Resolve Auto Layout Issues -> Add Missing Constraints (For All Views) if you want to use Auto Layout. Otherwise, look up some constraint tutorials and you'll have to set them manually. It's not too bad once you get the hang out it!

Launch image adds margin

After adding my launch image using a xib (and I even tried the traditional launch image way as well) some of my view controllers have a strange right margin now. For example before I might have had a label whose width was the entire screen, and used auto layouts such that it was leading/trailing to the content margins, and now despite that after adding a launch image there is a margin (it's not on every screen, but definitely some). On one of my screens where this is most prevalent i'm using autolayout but overriding with constraints that I add programmatically. Not sure if that's related.
Has anyone experienced anything like this or does anyone know if adding launch screens affect the story board / view controllers in any way?
Thanks!
On the launch screen select your image view, then select the pin at the bottom right of xcode (3rd option). Make sure all constraints are set to 0, while making sure the red I is selected for each one when they are set and uncheck constraint to margins. Finally click add constraints :)
Hope this helps you!
Rachel

UIView Doesn't allow swipe down to see rest of the screen

I build a view that has contents which exceed the height of the iphone 6 screen vertically.
To test that out, I've set a specific height for my image (600pts) to guarantee that the whole content wouldn't fit on the screen of an iphone 6 and that you should swipe down to see the rest (the label "BYE").
However, when I run the simulator, I cannot swipe down to see the rest of the screen.
I've used Autolayout constraint and set a margin top/bottom between each components and the superview (I don't have any autolayout constraints issues/warning).
Here's the screenshot of the storyboard of my UIViewController:
Here's when I run the simulator, I cannot see the Label "BYE"(which is normal) but I cannot swipe down to see it.
I am using Xcode 6.1 and Swift.
Any suggestion and explanations?
Thanks a lot!
I have redone your screen and here are the steps. The reason for your issue is not setting proper constraints in autolayout. First you need to choose AnyWidth AnyHeight in Xcode which is in bottom of the storyboard.
Here is the screenshots of View in StoryBoard and its constraints
Constraints
Final Result in Simulator
Setting the constraint properly will work for you. Let me know if you have any issues in doing so. Sorry for the image i used its low quality one and its just for test.
EDIT
In Storyboard if you see the bottom of the screen you will see below image. In center of that image there is wAnyhAny.
you need add constraint to thoes components!
Otherwise, some components will be placed out of the screen!
You can learn how to use Autolayout from here
![enter image description here][1]At right bottom of storyboard in xcode you will see triangel Resolve autolayout isuue select in Reset to suggested constraint.

AutoLayout positioning problems in iPhone

My problem is on rotation (rotate left/rotate right), the UIImageView that I have created touching the bottom of the screen (which also has 2 buttons within it) disappears. I did a search in Stack Overflow and other online forums and I haven't been able to address this problem at all.
I have checked the "Use Auto Layout" option as well. I tried specifying various alignment constraints but to no avail. All I want is the UIImageView to be visible (along with the 2 buttons within it) when I rotate the device left/right. Xcode version 5.1.1, emulator type iPhone Retina (4-inch). Kindly let me know if you need any further information. Appreciate some help!
Does this image help or you need further explanation?
I added a button and specified a fixed width (200), as well as a leading and bottom space of 10 to its superview. That means that this button will always be at the bottom left corner.

Resources