Skip to content

Commit 7fe8d1c

Browse files
authored
fix(tabs-ios9): no view controller managing visible view error (#7837)
1 parent ff30c48 commit 7fe8d1c

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

tests/app/ui/image-cache/image-cache-tests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as imageCacheModule from "tns-core-modules/ui/image-cache";
22
import * as imageSource from "tns-core-modules/image-source";
33
import * as types from "tns-core-modules/utils/types";
4+
import { isAndroid } from "tns-core-modules/platform";
45
import { device } from "tns-core-modules/platform";
56
import lazy from "tns-core-modules/utils/lazy";
67

@@ -10,7 +11,7 @@ const sdkVersion = lazy(() => parseInt(device.sdkVersion));
1011

1112
export const test_ImageCache_ValidUrl = function() {
1213
// see https://github.com/NativeScript/NativeScript/issues/6643
13-
if (sdkVersion() < 20) {
14+
if (isAndroid && sdkVersion() < 20) {
1415
return;
1516
}
1617

tests/app/xml-parser-tests/xml-parser-tests.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import * as TKUnit from "../tk-unit";
66
import * as xmlModule from "tns-core-modules/xml";
77
import * as fs from "tns-core-modules/file-system";
88
import * as builder from "tns-core-modules/ui/builder";
9+
import { isIOS } from "tns-core-modules/platform";
10+
import { device } from "tns-core-modules/platform";
11+
import lazy from "tns-core-modules/utils/lazy";
12+
13+
const sdkVersion = lazy(() => parseInt(device.sdkVersion));
914

1015
export var test_XmlParser_IsDefined = function () {
1116
TKUnit.assertNotEqual(xmlModule.XmlParser, undefined, "Class XmlParser should be defined!");
@@ -94,6 +99,10 @@ export var test_XmlParser_OnErrorIsCalledWhenAnErrorOccurs = function () {
9499
};
95100

96101
export var test_XmlParser_IntegrationTest = function () {
102+
if (isIOS && sdkVersion() < 10) {
103+
return;
104+
}
105+
97106
var actualResult = "";
98107
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
99108
if (event.eventType === xmlModule.ParserEventType.Text && event.data.trim() === "") {
@@ -194,6 +203,10 @@ export var test_XmlParser_DummyDocumentationTest = function () {
194203
};
195204

196205
export var test_XmlParser_NamespacesTest = function () {
206+
if (isIOS && sdkVersion() < 10) {
207+
return;
208+
}
209+
197210
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
198211
if (event.eventType !== xmlModule.ParserEventType.StartElement) {
199212
return;

tns-core-modules/ui/tabs/tabs.ios.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ import { swipeEnabledProperty, TabsBase } from "./tabs-common";
2222
export * from "./tabs-common";
2323

2424
const majorVersion = iosUtils.MajorVersion;
25-
// const isPhone = device.deviceType === "Phone";
25+
26+
// Equivalent to dispatch_async(dispatch_get_main_queue(...)) call
27+
const invokeOnRunLoop = (function() {
28+
const runloop = CFRunLoopGetMain();
29+
30+
return (action: () => any) => {
31+
CFRunLoopPerformBlock(runloop, kCFRunLoopDefaultMode, action);
32+
CFRunLoopWakeUp(runloop);
33+
};
34+
}());
2635

2736
class MDCTabBarDelegateImpl extends NSObject implements MDCTabBarDelegate {
2837
public static ObjCProtocols = [MDCTabBarDelegate];
@@ -1052,6 +1061,11 @@ export class Tabs extends TabsBase {
10521061
this._currentNativeSelectedIndex = value;
10531062
this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => {
10541063
if (finished) {
1064+
if (majorVersion < 10) {
1065+
// HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606
1066+
invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null));
1067+
}
1068+
10551069
this._canSelectItem = true;
10561070
this._setCanBeLoaded(value);
10571071
this._loadUnloadTabItems(value);

0 commit comments

Comments
 (0)