Skip to content

Commit 4d70619

Browse files
committed
Merge pull request #119 from mRs-/hidden-bugfix
UINavigationBar isHidden bugfix
2 parents f1c2e26 + 0ef97b6 commit 4d70619

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ If you have ideas how to improve this library please let me know or send a pull
8686
Changes
8787
-----
8888
89+
**0.9.6**
90+
* Fixed a Position bug when you hide the UINavigationBar with the UINavigationBar hidden property.
91+
8992
**0.9.5**
9093
* Fixed warnings
9194
* Other little bugfixes

TSMessages/Classes/TSMessage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,9 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) {
165165
This depends on the Base SDK and the currently used device */
166166
+ (BOOL)iOS7StyleEnabled;
167167

168+
/** Indicates whether the current navigationBar is hidden by isNavigationBarHidden
169+
on the UINavigationController or isHidden on the navigationBar of the current
170+
UINavigationController */
171+
+ (BOOL)isNavigationBarInNavigationControllerHidden:(UINavigationController *)navController;
172+
168173
@end

TSMessages/Classes/TSMessage.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ - (void)fadeInCurrentNotification
212212

213213
BOOL isViewIsUnderStatusBar = [[[currentNavigationController childViewControllers] firstObject] wantsFullScreenLayout];
214214
if (!isViewIsUnderStatusBar && currentNavigationController.parentViewController == nil) {
215-
isViewIsUnderStatusBar = ![currentNavigationController isNavigationBarHidden]; // strange but true
215+
isViewIsUnderStatusBar = ![TSMessage isNavigationBarInNavigationControllerHidden:currentNavigationController]; // strange but true
216216
}
217-
if (![currentNavigationController isNavigationBarHidden])
217+
if (![TSMessage isNavigationBarInNavigationControllerHidden:currentNavigationController])
218218
{
219219
[currentNavigationController.view insertSubview:currentView
220220
belowSubview:[currentNavigationController navigationBar]];
@@ -303,6 +303,17 @@ - (void)fadeInCurrentNotification
303303
}
304304
}
305305

306+
+ (BOOL)isNavigationBarInNavigationControllerHidden:(UINavigationController *)navController
307+
{
308+
if([navController isNavigationBarHidden]) {
309+
return YES;
310+
} else if ([[navController navigationBar] isHidden]) {
311+
return YES;
312+
} else {
313+
return NO;
314+
}
315+
}
316+
306317
- (void)fadeOutNotification:(TSMessageView *)currentView
307318
{
308319
currentView.messageIsFullyDisplayed = NO;

TSMessages/Views/TSMessageView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ - (CGFloat)updateHeightOfMessageView
422422
if (!navigationController && [self.viewController isKindOfClass:[UINavigationController class]]) {
423423
navigationController = (UINavigationController *)self.viewController;
424424
}
425-
BOOL isNavBarIsHidden = !navigationController || self.viewController.navigationController.navigationBarHidden;
425+
BOOL isNavBarIsHidden = !navigationController || [TSMessage isNavigationBarInNavigationControllerHidden:self.viewController.navigationController];
426426
BOOL isNavBarIsOpaque = !self.viewController.navigationController.navigationBar.isTranslucent && self.viewController.navigationController.navigationBar.alpha == 1;
427427

428428
if (isNavBarIsHidden || isNavBarIsOpaque) {

0 commit comments

Comments
 (0)