@@ -20,16 +20,26 @@ const isPhone = Device.deviceType === 'Phone';
2020@NativeClass
2121class MDTabBarControllerImpl extends UITabBarController {
2222 private _owner : WeakRef < BottomNavigation > ;
23+ private _preventTraitCollectionChanges : boolean ;
2324
2425 public static initWithOwner ( owner : WeakRef < BottomNavigation > ) : MDTabBarControllerImpl {
2526 const handler = MDTabBarControllerImpl . alloc ( ) . init ( ) as MDTabBarControllerImpl ;
2627 handler . _owner = owner ;
28+ handler . _preventTraitCollectionChanges = false ;
2729
2830 return handler ;
2931 }
3032
3133 public viewDidLoad ( ) {
3234 super . viewDidLoad ( ) ;
35+ if ( SDK_VERSION >= 18 ) {
36+ try {
37+ this . _preventTraitCollectionChanges = true ;
38+ this . traitOverrides . horizontalSizeClass = UIUserInterfaceSizeClass . Compact ;
39+ } finally {
40+ this . _preventTraitCollectionChanges = false ;
41+ }
42+ }
3343 this . tabBar . backgroundColor = new Color ( '#fff' ) . ios ;
3444 }
3545
@@ -61,9 +71,12 @@ class MDTabBarControllerImpl extends UITabBarController {
6171
6272 public viewWillTransitionToSizeWithTransitionCoordinator ( size : CGSize , coordinator : UIViewControllerTransitionCoordinator ) : void {
6373 super . viewWillTransitionToSizeWithTransitionCoordinator ( size , coordinator ) ;
74+ if ( ! this . _owner ?. get ( ) ) {
75+ return ;
76+ }
6477 coordinator . animateAlongsideTransitionCompletion ( ( ) => {
65- const owner = this . _owner . get ( ) ;
66- if ( owner && owner . tabStrip && owner . tabStrip . items ) {
78+ const owner = this . _owner ? .get ( ) ;
79+ if ( owner ? .tabStrip ? .items ) {
6780 const tabStrip = owner . tabStrip ;
6881 tabStrip . items . forEach ( ( tabStripItem ) => {
6982 updateBackgroundPositions ( tabStrip , tabStripItem ) ;
@@ -79,14 +92,13 @@ class MDTabBarControllerImpl extends UITabBarController {
7992 // Mind implementation for other controllers
8093 public traitCollectionDidChange ( previousTraitCollection : UITraitCollection ) : void {
8194 super . traitCollectionDidChange ( previousTraitCollection ) ;
95+ if ( this . _preventTraitCollectionChanges ) {
96+ return ;
97+ }
8298
8399 if ( SDK_VERSION >= 13 ) {
84- const owner = this . _owner . get ( ) ;
85- if (
86- owner &&
87- this . traitCollection . hasDifferentColorAppearanceComparedToTraitCollection &&
88- this . traitCollection . hasDifferentColorAppearanceComparedToTraitCollection ( previousTraitCollection )
89- ) {
100+ const owner = this . _owner ?. get ( ) ;
101+ if ( owner && this . traitCollection . hasDifferentColorAppearanceComparedToTraitCollection ?.( previousTraitCollection ) ) {
90102 owner . notify ( {
91103 eventName : IOSHelper . traitCollectionColorAppearanceChangedEvent ,
92104 object : owner
0 commit comments