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

[TIMOB-25942] : iOS 11: Screen orientation not working in navigation window #10104

Merged
merged 4 commits into from
Sep 27, 2018
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
11 changes: 9 additions & 2 deletions iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,15 @@ - (void)refreshOrientationWithDuration:(id)unused
#ifdef FORCE_WITH_MODAL
[self forceRotateToOrientation:target];
#else
[self rotateHostingViewToOrientation:target
fromOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
if ([TiUtils isIOSVersionOrGreater:@"11.0"] && [TiUtils isIOSVersionLower:@"12.0"]) {
forcingStatusBarOrientation = YES;
[[UIApplication sharedApplication] setStatusBarOrientation:target animated:NO];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is deprecated in iOS 9+, we should use a wrapper to use the iOS 10+ API for newer devices.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vijaysingh-axway Can you add the [TiUtils isLowerThan:@"12.0"] (or how the method was named) check to only add this workaround for iOS 11?

[UIViewController attemptRotationToDeviceOrientation];
forcingStatusBarOrientation = NO;
} else {
[self rotateHostingViewToOrientation:target
fromOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
}
forcingRotation = NO;
#endif
} else {
Expand Down
63 changes: 63 additions & 0 deletions tests/Resources/ti.ui.window.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* global Ti */
/* eslint no-unused-expressions: "off" */
'use strict';
var should = require('./utilities/assertions');

describe('Titanium.UI.Window', function () {
var win,
rootWindow;

this.timeout(5000);

// Create and open a root window for the rest of the below child window tests to use as a parent.
// We're not going to close this window until the end of this test suite.
// Note: Android needs this so that closing the last window won't back us out of the app.
before(function (finish) {
rootWindow = Ti.UI.createWindow();
rootWindow.addEventListener('open', function () {
finish();
});
rootWindow.open();
});

after(function (finish) {
rootWindow.addEventListener('close', function () {
finish();
});
rootWindow.close();
});

afterEach(function () {
if (win) {
win.close();
}
win = null;
});

it.ios('.statusBarStyle', function (finish) {
win = Ti.UI.createWindow({
title: 'This is status bar style test',
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
});

win.addEventListener('open', function () {
try {
should(win.statusBarStyle).be.a.Number;
should(win.statusBarStyle).eql(Ti.UI.iOS.StatusBar.LIGHT_CONTENT);
win.setStatusBarStyle(Ti.UI.iOS.StatusBar.GRAY);
should(win.statusBarStyle).eql(Ti.UI.iOS.StatusBar.GRAY);
finish();
} catch (err) {
finish(err);
}
});
win.open();
});
});