Skip to content

Commit

Permalink
Merge pull request #128 from Sipeso/iOS11NavigationBarFix
Browse files Browse the repository at this point in the history
iOS 11 Bugfix: Find the correct container-view when a poptip is prese…
  • Loading branch information
kleinlieu committed Aug 24, 2017
2 parents c9ab6ae + d2c138e commit f6fac05
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions CMPopTipView/CMPopTipView.m
Expand Up @@ -615,8 +615,15 @@ - (void)presentPointingAtView:(UIView *)targetView inView:(UIView *)containerVie

- (void)presentPointingAtBarButtonItem:(UIBarButtonItem *)barButtonItem animated:(BOOL)animated {
UIView *targetView = (UIView *)[barButtonItem performSelector:@selector(view)];
UIView *targetSuperview = [targetView superview];
UIView *containerView = [targetSuperview superview];
// Try to find the superview of the UINavigationBar. Limit the number of tries to 8.
UIView *containerView = targetView.superview;
for(NSInteger i = 0; i < 8; ++i) {
if([containerView isKindOfClass:[UINavigationBar class]]) {
containerView = containerView.superview;
break;
}
containerView = containerView.superview;
}

if (nil == containerView) {
NSLog(@"Cannot determine container view from UIBarButtonItem: %@", barButtonItem);
Expand Down

0 comments on commit f6fac05

Please sign in to comment.