Skip to content

Commit

Permalink
Pull from the root TabBarController (#4637)
Browse files Browse the repository at this point in the history
  • Loading branch information
paubins authored and yogevbd committed Jan 31, 2019
1 parent 0bcfbb7 commit 8cee745
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ios/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ + (CGFloat)statusBarHeight {
}

+ (CGFloat)bottomTabsHeight {
return UIApplication.sharedApplication.delegate.window.rootViewController.tabBarController.tabBar.frame.size.height;
return CGRectGetHeight(((UITabBarController *)((UIWindow *)(UIApplication.sharedApplication.windows[0])).rootViewController).tabBar.frame);
}

@end

1 comment on commit 8cee745

@MrtnvM
Copy link

@MrtnvM MrtnvM commented on 8cee745 Feb 14, 2019

Choose a reason for hiding this comment

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

Hi! Your way of getting tab bar height leads to a crash. Please replace this method by pointed below. It will increase the stability of the library

- (CGFloat)bottomTabsHeight {
    UIViewController *rootViewController = [[UIApplication.sharedApplication keyWindow] rootViewController];
    
    if ([rootViewController isKindOfClass:[UITabBarController class]]) {
        return [((UITabBarController *)rootViewController) tabBar].frame.size.height;
    }
    
    return [[rootViewController tabBarController] tabBar].frame.size.height ?: 0;
}

Please sign in to comment.