Drew S.
Drew S.

Reputation: 526

Some iOS constraints not working in Xcode 8 (after conversion to Swift 3)

I have quite a lot of views that are created with storyboards. Everything except 2 items in the views are not working correctly and it has to do with the constraints. It is almost like the constraints simply are not working or something.

When I am in the storyboard mode and change the constant value on the constraints, then 'update frames' nothing happens. It doesn't shift around like it typically does when constraints change.

This is inside a table cell. I have a view that is .5 thick that I want to stick to the bottom, and then I want it to extend to the trailing edge and to the leading. When I set any of these constraints then press 'update frames', nothing happens.

The other control I'm having an issue with is a TextView. It seems to have no height when in the application so again, something is going on with the constraints. This looks to be the same thing happening in this case too.

I have tried recreating the view in Xcode 8 (just this one view that I'm having issues with inside my storyboard) and I get the same weird behavior. I also tried saving it as Xcode 7.x mode as suggested in another thread, and I've also tried setting viewNeedsLayout in the code. Neither of those are working.

Any suggestions?

Upvotes: 1

Views: 855

Answers (2)

shallowThought
shallowThought

Reputation: 19602

I see this issue here too. As a workaround:

  • Drag the affected view to a slightly other position (in Storyboard). Now the (->) shows up to signal the current position does not match the constraints:

enter image description here

  • Click the (->)and choose "fix misplacements":

enter image description here

Upvotes: 1

Drew S.
Drew S.

Reputation: 526

So I've now figured out issues for both of my issues.

  1. It was a view that was 0.5 height but it did not have a constraint to be at that height. I added a constraint, updated frames, and it updated to be correct as I would expect.

No clue how something like this could be fine in Xcode 7 then in Xcode 8 it works. Apple really doesn't make developing easy huh.

2. The textview I was using had a height constraint set to <= 107. Well I changed it to = 107 and now it works fine. = actually works for me too since I'm changing the constant dynamically in the code anyways. However, again, I still have no clue why this would work fine in Xcode 7 and not Xcode 8.

Upvotes: 0

Related Questions