Simulator Constraints -- I can tell I'm missing something

25 views Asked by At

So I'm in XCode trying to make adaptive layouts by assigning my constraints to the different versions of width and height, namely Compact vs Regular. But I can tell something isn't clicking.

In my storyboard, I have this setup on an iPhone 15 Pro Max because it has wC, hR in portrait mode, and wR, hC in landscape mode:

enter image description here

This screen has a series of constraints set up that ONLY apply to the wC, hR screens so I can change what constraints I use for the landscape version. Speaking of, here's that:

enter image description here

It looks plenty good in the storyboard, but when I run the simulator, weird things happen. The first problem is that the orange and red views completely disappear once I switch to landscape mode, but I'm guessing that's just because of some oversight on my end. There are some things, however, that are totally out of my scope of knowledge.

For example, I had all orientations checked in the project target. But when I ran the simulator, I could tell that for some reason Portrait and Upside Down seem to be completely different to the program. Upside Down doesn't act like Portrait but flipped, and some of the orientations simply don't activate when they should. I found out that in order to get all the orientations working, I'd have to do more work than that-- but I'm low on time and don't have time to learn about it at the moment. So, I just went back to the project target and unchecked Upside Down and Landscape Right, hoping it would solve the issues.

However, it did not. If I launch the app in the simulator while the simulator is in landscape mode, then switch the orientation back to Portrait, I get this:

enter image description here

The constraints are completely messed up, and as long as this instance of the app is running, the portrait mode will always look like this.

Lastly, If I launch the simulator app while simulator is in portrait mode, then change the orientation enough times that I end up back on portrait, my app ends up like this:

enter image description here

and I get a crash error in the AppDelegate:

Thread 1: EXC_BREAKPOINT (code=1, subcode=0x180dd4790)

My research so far has only suggested that my constraints aren't being properly loaded and my code is crashing because the app is trying to access something that doesn't exist. If that's the case, then I'm definitely missing something big, because it doesn't make any sense to me that my constraints should load just fine the first time, but as soon as they're called again, they just no longer exist.

Obviously I know there's a lot of information on this post, and I'm not hoping for someone to explain it all to me from scratch. Instead, I'd love pointers to articles or documentation to read to better understand this behavior, or even just proper labels for this issue so I can properly research it.

0

There are 0 answers