Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationController.hidesBarsOnSwipe=YES leads to NSInternalInconsistencyException

I have a UITableViewController embedded in a UINavigationController. Everything works fine, until i set the UINavigationController's property hidesBarsOnSwipe to YES in viewWillAppear. If the user is going to scroll slightly nervously up and down, the app crashes with the following message:

2016-10-10 13:47:27.973 xxx[4246:1716033] *** Assertion failure in -[_UIAnimationCoordinator finishInteractiveAnimation], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.12/_UIAnimationCoordinator.m:154
2016-10-10 13:47:27.974 xxx[4246:1716033] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Trying to finish an interactive transition that was not started interactively'

The following Code seems to be a workaround, but nevertheless, I'd rather figure out, if someone else had a similar issue and maybe found a better solution. Thank you in advance!

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if(scrollView.contentOffset.y <= 10)
    {
        //scrollup
        scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
        [self.navigationController setNavigationBarHidden: NO animated:YES];
    }
    else if(scrollView.contentOffset.y >= 10)
    {
        //scrolldown
        [self.navigationController setNavigationBarHidden: YES animated:YES];
    }        
}

Btw: I can reproduce this behaviour in iOS 9.3.5 and 10.0.2 on Simulators and Devices using XCode 7.3

like image 464
Peter Grundner Avatar asked Nov 08 '22 07:11

Peter Grundner


1 Answers

For everyone, who have same problem and go to this page like me.

I fix that just open attributes inspector navigation controller "Hide Bars" -> "On swipe"(uncheck).

Hope it's help somebody.

(xcode 11.5, OS 13.5.1)

like image 86
John Avatar answered Nov 14 '22 21:11

John