UILabel getting clipped on 3.5" iPhone 4 screen? - ios

Can someone help me figure this out: I have done some research around here but nothing seems to work. I have tried working with the size inspector, I have also tried adding the following to my view with no success
[view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
I would really appreciate some help here, thanks!

This can be fixed by using autolayout like shown below.
Have a look at this tutorial on how to use it: http://www.raywenderlich.com/20881/

Use auto layout and constraints. You need to click on UILabel and press "Control" button and drag the cursor downwards and then select the bottom space constraint. Like wise you need to set all the constraints for X, Y , Height and Width of the UILabel and you should be good to see the label at the same place on all kinds of devices.

Related

UITextView is not displayed

I create a contact form and therefore I use a UITextView in my storyboard but when I launch the application, my UITextView is not displayed ...: /
Someone would have the solution to this bug? The only tool I can give you is a screenshot because there is almost no code.
Thank you in advance for your help ! And especially Happy New Year everyone!
Explications
Your UITextView doesn’t know its height.
You have to set its bottom constraint or height constraint (in this case bottom constraint equal to Emvoyer button’s top constraint seems correct).

How to adjust this view with constraints

I'm totally new to Swift and in general, to iOS development. I just want to center a rounded profile picture with a table view above. In iPhone 5 it looks centered, but in iPhone 6 and 7 it look aligned to left, I don't know how to fix with constraints, I'm a little bit confuse.
This is my constraint tree:
How it looks storyboard for iPhone5
How it looks storyboard for iPhone 6/7
This is how it looks in emulator with iPhone 6
Can you guys help me to figure out what I'm doing wrong?
Thanks in advance!
Cheers.
It looks like you've set the width and height of your image view to hard-coded values, which will result in it looking centred for some views, but not all.
Reset your constraints, then set your distance from each of the four sides to zero. That'll centre your image!
Go to Editor -> Resolve Auto Layout Issues -> Reset to Suggested Constraints...
...then click that button down the bottom right and set each of your four sides' distances to zero.
Make sure you set Update Frames to "All Frames in Container" before clicking "Add 4 Constraints".
Try setting horizontal constrain between your My UI Image View and HeaderView. You can set centre hozintal with HeaderView.
Go to button down the bottom right and set centre vertical and centre horizontal to your My UI Image View.
Hope it helps. Happy Coding!!

IOS/Storyboard/Autolayout: Center round button under horizontal bar

This should be incredibly simple but somehow has proven incredibly complicated for me with auto layout.
I have a horizontal bar shaped button. I want to center a round information icon below it. Auto layout keeps trying to stretch the round button into an oval and is not centering it from left to right as in the following:
The above is the result of the following constraints that should work but don't.
Can anyone please tell me the correct constraints to add to accomplish this simple task.
Thank you.
If the image is being stretched, then set its contentMode to be aspectFit or aspectFill.
Once that is done, you can add a constraint to the image so that it and the login button share vertical centers.
Can you see this yellow box showing in your view? It's showing a warning that means the view which is selected right now should be placed here according to the defined constraints. I guess the constraints of this view are conflicting with other views. Try to resolve this warning by adding "suggested" constraints or by fixing misplacement. I hope it'll work, if not then give me your code I'll resolve that issue for you.

UITextView wrong content position with auto layout

I have a UITextView in UIViewController with auto layout:
The TextView size changes proportionally in accordance to the View (for example on rotation, or run on different dispositive iPhone 4s..6s).
Unfortunately the content text doesn't show from first line:
I suppose that the content inset is wrong but I don't have a solution.
I don't use Interface Builder - so I'm sure someone can correct me if I'm wrong, or, see the mistake if I've missed it...
But, from your screen shot (resolution is a bit low) it looks like you've got vertical constraints when positioning the text view: there's a value showing a spacing between the view and Top Layout Guide (and again for the bottom layout guide). You could just delete these...
Specifically:
Top space to equals 135
Bottom space to equals 106
As for your second screen shot, I'm not sure if it's a different device to the image on the right... but maybe the sample text just doesn't fit in the view, and it's scrolled to the bottom of the text. That would make it look like the top text is cut off, because it's clipped by the top of the UITextView.
I had the same problem, and I tried all of the work-arounds to setContentOffset and/or scrollRangeToVisible to no avail.
I was inspired by this SO post:
https://stackoverflow.com/a/21287306/610550
I ended up disabling scrolling on the textView on the storyboard, and then using self.textView.scrollEnabled = true in viewDidLoad(). It worked perfectly!

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!

Resources