mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(ios): Objective-C class name "UITabBar..." already in use handling
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
"main": "index",
|
"main": "index",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"description": "NativeScript Core Modules",
|
"description": "NativeScript Core Modules",
|
||||||
"version": "6.5.17",
|
"version": "6.5.18",
|
||||||
"homepage": "https://www.nativescript.org",
|
"homepage": "https://www.nativescript.org",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -18,12 +18,18 @@ export * from "./tab-view-common";
|
|||||||
const majorVersion = iosUtils.MajorVersion;
|
const majorVersion = iosUtils.MajorVersion;
|
||||||
const isPhone = device.deviceType === "Phone";
|
const isPhone = device.deviceType === "Phone";
|
||||||
|
|
||||||
class UITabBarControllerImpl extends UITabBarController {
|
let UITabBarControllerImpl;
|
||||||
|
let UITabBarControllerDelegateImpl;
|
||||||
|
let UINavigationControllerDelegateImpl;
|
||||||
|
|
||||||
|
const setupControllers = function () {
|
||||||
|
if (typeof UITabBarControllerImpl === 'undefined') {
|
||||||
|
class UITabBarControllerClass extends UITabBarController {
|
||||||
|
|
||||||
private _owner: WeakRef<TabView>;
|
private _owner: WeakRef<TabView>;
|
||||||
|
|
||||||
public static initWithOwner(owner: WeakRef<TabView>): UITabBarControllerImpl {
|
public static initWithOwner(owner: WeakRef<TabView>): typeof UITabBarControllerImpl {
|
||||||
let handler = <UITabBarControllerImpl>UITabBarControllerImpl.new();
|
let handler = <typeof UITabBarControllerImpl>UITabBarControllerImpl.new();
|
||||||
handler._owner = owner;
|
handler._owner = owner;
|
||||||
|
|
||||||
return handler;
|
return handler;
|
||||||
@ -85,14 +91,15 @@ class UITabBarControllerImpl extends UITabBarController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UITabBarControllerImpl = UITabBarControllerClass;
|
||||||
|
|
||||||
class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControllerDelegate {
|
class UITabBarControllerDelegateClass extends NSObject implements UITabBarControllerDelegate {
|
||||||
public static ObjCProtocols = [UITabBarControllerDelegate];
|
public static ObjCProtocols = [UITabBarControllerDelegate];
|
||||||
|
|
||||||
private _owner: WeakRef<TabView>;
|
private _owner: WeakRef<TabView>;
|
||||||
|
|
||||||
public static initWithOwner(owner: WeakRef<TabView>): UITabBarControllerDelegateImpl {
|
public static initWithOwner(owner: WeakRef<TabView>): typeof UITabBarControllerDelegateImpl {
|
||||||
let delegate = <UITabBarControllerDelegateImpl>UITabBarControllerDelegateImpl.new();
|
let delegate = <typeof UITabBarControllerDelegateImpl>UITabBarControllerDelegateImpl.new();
|
||||||
delegate._owner = owner;
|
delegate._owner = owner;
|
||||||
|
|
||||||
return delegate;
|
return delegate;
|
||||||
@ -132,14 +139,15 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
|
|||||||
(<any>tabBarController)._willSelectViewController = undefined;
|
(<any>tabBarController)._willSelectViewController = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UITabBarControllerDelegateImpl = UITabBarControllerDelegateClass;
|
||||||
|
|
||||||
class UINavigationControllerDelegateImpl extends NSObject implements UINavigationControllerDelegate {
|
class UINavigationControllerDelegateClass extends NSObject implements UINavigationControllerDelegate {
|
||||||
public static ObjCProtocols = [UINavigationControllerDelegate];
|
public static ObjCProtocols = [UINavigationControllerDelegate];
|
||||||
|
|
||||||
private _owner: WeakRef<TabView>;
|
private _owner: WeakRef<TabView>;
|
||||||
|
|
||||||
public static initWithOwner(owner: WeakRef<TabView>): UINavigationControllerDelegateImpl {
|
public static initWithOwner(owner: WeakRef<TabView>): typeof UINavigationControllerDelegateImpl {
|
||||||
let delegate = <UINavigationControllerDelegateImpl>UINavigationControllerDelegateImpl.new();
|
let delegate = <typeof UINavigationControllerDelegateImpl>UINavigationControllerDelegateImpl.new();
|
||||||
delegate._owner = owner;
|
delegate._owner = owner;
|
||||||
|
|
||||||
return delegate;
|
return delegate;
|
||||||
@ -171,6 +179,12 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UINavigationControllerDelegateImpl = UINavigationControllerDelegateClass;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
setupControllers();
|
||||||
|
|
||||||
function updateTitleAndIconPositions(tabItem: TabViewItem, tabBarItem: UITabBarItem, controller: UIViewController) {
|
function updateTitleAndIconPositions(tabItem: TabViewItem, tabBarItem: UITabBarItem, controller: UIViewController) {
|
||||||
if (!tabItem || !tabBarItem) {
|
if (!tabItem || !tabBarItem) {
|
||||||
@ -256,11 +270,11 @@ export class TabViewItem extends TabViewItemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TabView extends TabViewBase {
|
export class TabView extends TabViewBase {
|
||||||
public viewController: UITabBarControllerImpl;
|
public viewController: typeof UITabBarControllerImpl;
|
||||||
public items: TabViewItem[];
|
public items: TabViewItem[];
|
||||||
public _ios: UITabBarControllerImpl;
|
public _ios: typeof UITabBarControllerImpl;
|
||||||
private _delegate: UITabBarControllerDelegateImpl;
|
private _delegate: typeof UITabBarControllerDelegateImpl;
|
||||||
private _moreNavigationControllerDelegate: UINavigationControllerDelegateImpl;
|
private _moreNavigationControllerDelegate: typeof UINavigationControllerDelegateImpl;
|
||||||
private _iconsCache = {};
|
private _iconsCache = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"main": "index",
|
"main": "index",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"description": "NativeScript Core Modules",
|
"description": "NativeScript Core Modules",
|
||||||
"version": "6.5.17",
|
"version": "6.5.18",
|
||||||
"homepage": "https://www.nativescript.org",
|
"homepage": "https://www.nativescript.org",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nativescript/core": "6.5.17"
|
"@nativescript/core": "6.5.18"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tns-platform-declarations": "6.5.15"
|
"tns-platform-declarations": "6.5.15"
|
||||||
|
Reference in New Issue
Block a user