Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): hierarchy error when using SplitWindow and NavigationWindow #12930

Merged
merged 5 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,20 @@ - (UIViewController *)hostingController;

- (UIViewController *)windowHoldingController
{
// Use assigned controller if set.
if (controller != nil) {
return controller;
} else {
return [[TiApp app] controller];
}

// Walk up the view hierarchy for the 1st controller available.
for (UIResponder *responder = [self view].nextResponder; responder != nil; responder = responder.nextResponder) {
if ([responder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)responder;
}
}

// Fallback to the app's root view controller.
return [[TiApp app] controller];
}

#pragma mark - Private Methods
Expand Down
22 changes: 22 additions & 0 deletions tests/Resources/ti.ui.ios.splitwindow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ describe.ios('Titanium.UI.iOS', function () {
should(splitWindow.masterView).be.an.Object();
should(splitWindow.detailView).be.an.Object();
});

// Verify view controller hierarchy is set up correctly. (Used to crash in 10.0.0. See: TIMOB-28497)
it('view controller hierarchy', function (finish) {
this.slow(2000);
this.timeout(5000);
const splitWindow = Ti.UI.iOS.createSplitWindow({
detailView: Ti.UI.createNavigationWindow({
window: Ti.UI.createWindow({ title: 'Detail View' }),
}),
masterView: Ti.UI.createNavigationWindow({
window: Ti.UI.createWindow({ title: 'Master View' }),
}),
showMasterInPortrait: true,
});
const navWindow = Ti.UI.createNavigationWindow({ window: splitWindow });
navWindow.addEventListener('postlayout', function listener() {
navWindow.removeEventListener('postlayout', listener);
navWindow.close();
finish();
});
navWindow.open();
});
});

// describe.ios('Titanium.UI.iOS.SplitWindow', function () {
Expand Down