Switch between CarPlay and regular window in iOS s

2019-04-15 07:08发布

问题:

I am testing an app that has some CarPlay functionalities. I activated the CarPlay window in the simulator by changing the default options using

defaults write com.apple.iphonesimulator CarPlay -bool YES

which works perfectly when it comes to starting up the CarPlay windows, either when the simulator starts automatically after the application is compiled in debug or if I manually open up the CarPlay window through Hardware -> External Displays -> CarPlay when the app is already running in the simulator. The problem is that, in both cases, the main simulator window goes dark (after showing the CarPlay splashscreen simmilar to the one seen on the phone in this image).

Now, I don't exactly know what the real life behavior is supposed to be, but I can't manage to simply execute a "shut-down" behavior on the CarPlay window and switch back to the main simulator window so that it displays the app (or anything else for that matter). Currently, if I got back to the simulator menu and select Hardware -> External Displays -> None, the CarPlay window simply dissapears, but the main simulator window stay blacked out.

So, my question is, how can one simulate a CarPlay "shutdown" behavior when using the simulator, and how can I get back the OS in the main simulator window ? On a more development focused side, I would also like to know exactly if and how I can detect that the Media Player becomes "turned off" when CarPlay shuts down, or, more specifically, if there is a way that one can programatically observe the event where the CarPlay's media control capabilities become "unavailable".

回答1:

I can only partially answer your question. To bring back the app itself or the OS main window, simply press (or simulate a press Shift+Cmd+H) of the home button.



回答2:

CarPlay "shutdown" behavior? No such thing.

If a user disconnects from the car - the UI is gone.

If you want to kill the app why in a CarPlay session - simply bring the iPhone simulator back into focus and unlock it (by tapping the Home button = Cmd+Shift+H). Then the iPhone should work. You should see the app close.