I’ve been able to get this working for both cases:
a) when my app starts full screen, and another app is dragged-in via the task bar
b) where another app starts first and my app is dragged-up via the task bar.
My solution thus far is pretty simple:
-
in the .plist file:
UIRequiresFullScreen
-
in juce_ios_UIViewComponentPeer.mm:
// Declare two statics (yes, ugly, I know!)
CGSize GUseWindowSize;
static bool GbGotUseWindowSize = false;
//...
// Modify method:
- (void) viewWillTransitionToSize: (CGSize) size withTransitionCoordinator: (id<UIViewControllerTransitionCoordinator>) coordinator
{
GUseWindowSize = size;
GbGotUseWindowSize = true;
//...
// Modify constructor UIViewComponentPeer::UIViewComponentPeer
//...
{
CGRect r = convertToCGRect (component.getBounds());
if (GbGotUseWindowSize) {
r.size = GUseWindowSize;
}
//...
// Modify UIWindow constructor:
//...
//window = [[JuceUIWindow alloc] initWithFrame: r];
window = [[JuceUIWindow alloc] init]; // Multitasking change
if (GbGotUseWindowSize == false) {
GbGotUseWindowSize = true;
GUseWindowSize = window.bounds.size;
view.bounds.size = GUseWindowSize;
}
// Disable flag setting:
//window.autoresizesSubviews = NO;
- Modify juce_ios_Windowing.mm
extern CGSize GUseWindowSize;
extern bool GbGotUseWindowSize;
void Desktop::Displays::findDisplays (float masterScale)
{
JUCE_AUTORELEASEPOOL
{
UIScreen* s = [UIScreen mainScreen];
auto theBounds = [s bounds];
if (GbGotUseWindowSize) {
theBounds.size = GUseWindowSize;
}
Display d;
d.userArea = d.totalArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt (theBounds)) / masterScale;
Of course, this is just a hack, maybe not all the changes are correct, and will no doubt need to be finessed.
That said: Jules & team - is there any chance you could merge-in a tidied-up version of the above into the code base?
Testing notes: to use multi-tasking on iPad, in case this helps!
- start your app
- drag-up enough to show the Task Bar
- select icon in task bar, and drag to left/right of the current app; it’ll show a window where you app will appear
- you can then drag the central splitter left/right to resize, or if you drag fully left/right both apps become full screen mode.
- only some apps work of course - including the built-in Reminders app (very useful for testing on Simulator!) and Safari.
Thanks,
Pete