Problem xcode emulator

Good morning to everyone. I have a big question with Xcode, to see if someone can help me, please. I explain: I am doing a view and I insert 3 buttons with their corresponding constraints. When I do a preview in xcode (using the editor settings), the view is perfect for me. But when I run it on an emulator for both iphone 8 or any other, the buttons are reduced or are out of place or do not appear ... and I do not understand what the problem is, due to the constraints and everything is perfect. Also, in the xcode when I select some iphone emulators I get 2 of the same type. For example, I get 2 from the iPhone SE (2nd generation), specifically I get iPhone SE (2nd generation) (040BBDPC-2F ....) and iPhone SE (2nd generation) (161B06F7-3DA ...),
Could someone help me or tell me something about this matter? I have had the project paralyzed almost 15 days ago. THANK YOU SO MUCH EVERYONE!!

Previews have the luxury of appearing as the only item on a screen. On the simulator, they must now obey the layout constraints placed on them by whatever parent they have. If that parent has too many children or is itself weirdly positioned, your perfectly working child will never the less be affected by this.

In my code, I have found that when this happens, it usually means I have too much code, I am trying to specify things too much. If I get rid of modifiers and parameters, usually the hiding child shows up, and I can tweak things again, one by one to see what happens.

If you are using explicit constraints, a rule of thumb is that one generally needs no more than 4 of them. You must somehow communicate the view's x and y position, and it's size. I often would find that if I had too many constraints on something, the system would get confused.

These questions are a bit off-topic for this forum. You'll get better help at the Apple Dev forum or SO.

Having said that, learn to use the Xcode View Debugger to figure things out.

Thank you very much. It is true that many times the fewer constraints you put, the better it goes. Thanks for the help.

1 Like

Why is it offtopic ?? .. because you say so ?? .. this is a forum dedicated to programming and Xcode is a programming tool. And not something from the operating system.
What if xcode is used, but this problem is driving me crazy. Please, if you are not going to help, you better not say anything. Thank you !!

It's off-topic because the guidelines that were setup by the forum creators make them off-topic. These forums are for discussions about the open-source Swift language and support infrastructure that should be applicable to all platforms, Darwin, Linux, Windows, zOS, etc.. When these forums were setup, the forum creators noted that there are plenty of resources available for Apple-specific frameworks, tools, and other infrastructure, and, because they did not want these discussions to devolve into Apple-only discussions, it was decided to discourage discussions of Apple-specific technologies and try to refer questioners elsewhere for answers. Note that Apple-private frameworks include SwiftUI and Combine, for which it seems more latitude is being given.

Xcode is a programming tool, but it is an Apple-only programming tool, and covers a wide variety of languages beyond just Swift. Thus, your question was marked off-topic.

ok Than you !!. i'll delete it.

No need to delete. Just a pointer that an answer to your question would probably be more available from Apple-specific resources.

Terms of Service

Privacy Policy

Cookie Policy