Strange Constraints Behaviour on iPad

Strange constraints behaviour on iPad

The problem is that you've connected your constraints to the superview's margins. If you want to reach the edge of the superview you need to connect to the superview itself (with a constant of zero).

Note the word "margin" in the constraint description:

enter image description here

The problem with connecting to the margins is that you do not know what the margins will be when the app runs. It is a risky strategy. But you do know where the edges of the view will be, so if you want to match them, constrain to them, not to the margins. Use the margins only if you really want to match the margins, whatever they may be. For example, a constraint with a constant of 0 to a margin guarantees a nice space to the edge of the superview. But you do not want any space!

Strange behaviour in Storyboard (Missing view when running app)

You have set the leading and trailing of the label . This will definitely happen because you have set the wrong constraints. Check the size of your view Controller where you have set the constraints, its (Any width , Any height).

Now, check in which size you are running, its (Compact width, Regular height). If you run it in a iPad you will find your label. Since, you have not fixed the width of your label, the label gets compressed when it is run. Try setting the width of your label and remove either the leading or the trailing constraint.

Else instead you can fix your width and select either the leading and trailing and set it to "less than equal to " rather than "equals to".

While designing imagine yourself holding the object keeping in mind about all possibilities that can occur and then set the constraints accordingly. A user can run your application in any size iPhone and iPad. So, the design should be such that it doesn't affect your objects in it.

If any problem occurs try view debugging then you can definitely find out where you have done wrong.

Autolayout requires negative constant to align with superview?

Any time I want the edges of a subview to align with the view controller's superview

No, that's not what you're doing. That's the problem. You have (accidentally) pinned your constraints to the superview's margin instead of its edge. There is a crucial difference between this:

enter image description here

and this (with the Option key held down):

enter image description here

iOS 7 + Auto Layout: Strange UIImageView behaviour

I'm sorry that I have to say this, but it was, as you certainly thought, my own fault.

The problem was that I made a photo with the iPad, and the iPad can be used in both orientations in this app. The photo was taken and was then used for an own view that allows the user to put annotations on the image.
The image gets then saved, and that was were the problem occured: I call

UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);

The landscape image was now taken into a portrait frame. After adjusting this and only allowing portrait mode, everything worked well.

Thanks anyways for your answers. And sorry for asking a question when the problem was another one and my own fault.

Strange alignment behaviour in UIImageView

Apply Constraints to your UIImageView.

Select the UIImageView in your NIB, then click on Editor > Pin > Leading Space to Superview. Then in the Attribute Inspector set Constant to 0. Do the same and apply Trainling Space to SuperView.

iOS origin? margin? error on iPad and iPhone 6+ with autolayout

Added a view to cover all the root view with green.

But you pinned it, with your constraints, to the root view's margins. Instead, pin it (with zero constant values) to the root view's edges.

AutoLayout constraints leadin & tailing acts different on iOS7 & iOS8

Turns out that the issue was "Relative to margin" after all. But instead of unchecking this option in UILabel constraints. I've to did it in UITableView and it works.



Related Topics



Leave a reply



Submit