ios – Odd side ratios on MTKView window whereas operating on Mac (designed for iPad) in landscape-only


I am constructing a sport on high of the essential Metallic Recreation pattern template in Goal-C from Xcode 14. To this point so good. Till I disabled all portrait modes and checked the “Requires fullscreen” field:

After I finished that, drawableSizeWillChange will get referred to as with the next values: CGSize(width = 3644, peak = 1535), which aren’t even below the 4:3 side ratio of the window. Inflicting the dice to appear like this:

It runs as anticipated on iPad and iPhone emulators. The difficulty appears to occur solely after I run it natively on macOS.

The remainder of the code remained just about untouched because it got here from Xcode’s pattern template.

It does not appear to occur on Swift’s model of this pattern. I could not discover any vital distinction within the code which may very well be producing such completely different outcomes throughout Obj-C and Swift variations.

Why is that? How can I be sure that the MTKView dimension will preserve window’s precise side ratio and ideally gadget/window native most decision?


Leave a Reply