Hello, everyone! I have a problem of identifying the screen size of different monitors in CarPlay. Does anyone know how to achieve it? UIScreen.main.bound does not help Thanks in advance!
How to detect screen size in CarPlay?
You can try UIScreen.main.applicationFrame in the didConnect template scene delegates but that might be the screen size for the iPhone or iPad.
This shows the sizes of iPhone screen but it does not show the size of the CarPlay screen
UIScreen.main will always return a UIScreen instance that corresponds to the iPhone's built-in display.
If your CarPlay-capable app is a Navigation app (and therefore receives a CPWindow to draw your map content into), you can get the UIScreen for the CarPlay display through your CPTemplateApplicationScene:
let carPlayScreen = templateApplicationScene.carWindow.screen
If your CarPlay-capable app is not a Navigation app, the template system should generally eliminate the need for your app to have different behavior or provide different content based on the screen size. If you believe you have a use case that requires direct knowledge of the screen's dimensions, please file a feedback for us and explain your needs!
Thanks!
Yes, I have an urgent need to know the dimensions of my screen. But it's not an initial problem. In my CarPlay application I am using CPGridTemplate. In my design I have to use 8 buttons that are aligned 4 buttons per row. According to the documentation, this is the default behavior. However, it is not working like this. I have filed this problem but have not got any response yet
https://developer.apple.com/forums/thread/726487
Hence, the only option to move my buttons is to add empty spaces, I'm need to satisfy 2 rows in various different screen sizes. That's why I have to calculate screen dimensions to know how many empty spaces I need to add. Ofc, adding empty spaces seem ridiculous, but this is the only working option right now