Skip to content

Commit

Permalink
Merge pull request #119 from mRs-/hidden-bugfix
Browse files Browse the repository at this point in the history
UINavigationBar isHidden bugfix
  • Loading branch information
mRs- committed Mar 7, 2014
2 parents f1c2e26 + 0ef97b6 commit 4d70619
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ If you have ideas how to improve this library please let me know or send a pull
Changes
-----
**0.9.6**
* Fixed a Position bug when you hide the UINavigationBar with the UINavigationBar hidden property.
**0.9.5**
* Fixed warnings
* Other little bugfixes
Expand Down
5 changes: 5 additions & 0 deletions TSMessages/Classes/TSMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,9 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) {
This depends on the Base SDK and the currently used device */
+ (BOOL)iOS7StyleEnabled;

/** Indicates whether the current navigationBar is hidden by isNavigationBarHidden
on the UINavigationController or isHidden on the navigationBar of the current
UINavigationController */
+ (BOOL)isNavigationBarInNavigationControllerHidden:(UINavigationController *)navController;

@end
15 changes: 13 additions & 2 deletions TSMessages/Classes/TSMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ - (void)fadeInCurrentNotification

BOOL isViewIsUnderStatusBar = [[[currentNavigationController childViewControllers] firstObject] wantsFullScreenLayout];
if (!isViewIsUnderStatusBar && currentNavigationController.parentViewController == nil) {
isViewIsUnderStatusBar = ![currentNavigationController isNavigationBarHidden]; // strange but true
isViewIsUnderStatusBar = ![TSMessage isNavigationBarInNavigationControllerHidden:currentNavigationController]; // strange but true
}
if (![currentNavigationController isNavigationBarHidden])
if (![TSMessage isNavigationBarInNavigationControllerHidden:currentNavigationController])
{
[currentNavigationController.view insertSubview:currentView
belowSubview:[currentNavigationController navigationBar]];
Expand Down Expand Up @@ -303,6 +303,17 @@ - (void)fadeInCurrentNotification
}
}

+ (BOOL)isNavigationBarInNavigationControllerHidden:(UINavigationController *)navController
{
if([navController isNavigationBarHidden]) {
return YES;
} else if ([[navController navigationBar] isHidden]) {
return YES;
} else {
return NO;
}
}

- (void)fadeOutNotification:(TSMessageView *)currentView
{
currentView.messageIsFullyDisplayed = NO;
Expand Down
2 changes: 1 addition & 1 deletion TSMessages/Views/TSMessageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ - (CGFloat)updateHeightOfMessageView
if (!navigationController && [self.viewController isKindOfClass:[UINavigationController class]]) {
navigationController = (UINavigationController *)self.viewController;
}
BOOL isNavBarIsHidden = !navigationController || self.viewController.navigationController.navigationBarHidden;
BOOL isNavBarIsHidden = !navigationController || [TSMessage isNavigationBarInNavigationControllerHidden:self.viewController.navigationController];
BOOL isNavBarIsOpaque = !self.viewController.navigationController.navigationBar.isTranslucent && self.viewController.navigationController.navigationBar.alpha == 1;

if (isNavBarIsHidden || isNavBarIsOpaque) {
Expand Down

0 comments on commit 4d70619

Please sign in to comment.