gmertk / BusyNavigationBar

A UINavigationBar extension to show loading effects
MIT License
990 stars 57 forks source link

Back button not working when animated #2

Closed prine closed 8 years ago

prine commented 9 years ago

Hello

First of all thanks for your library! I really like it and already used it in my application :). I found out that the back button is kind of blocked when the animation is running.

I found out that if you want to have the UIView still beeing responsive you need to add the options UIViewAnimationOptions.AllowUserInteraction. So I changed the following code from:

UIView.animateWithDuration(alphaAnimationDurationOfLoadingView, animations: { () -> Void in
    self.busy_loadingView!.alpha = self.busy_options.alpha
})

To this one:

UIView.animateWithDuration(alphaAnimationDurationOfLoadingView, delay: 0.0, options: UIViewAnimationOptions.AllowUserInteraction, animations: { () -> Void in
    self.busy_loadingView!.alpha = self.busy_options.alpha
}) { (finished) -> Void in
    // Finished..
}

But unfortunately the back button is still no responsive during animation..

Tested with IOS 8.4 Xcode 6.4 (iPhone Simulator)

gmertk commented 9 years ago

Thank your for reporting both of the issues :+1: I get you back about them during the weekend.

gmertk commented 9 years ago

I am thinking about 2 solutions for this problem:

  1. Whenever the number of navbar's subviews changes, remove and re-insert the loading animation layer above the navbar's background view.
  2. Instead of inserting view, insert layer into _UINavigationBarBackground directly.

Trying number 2 at the moment. Will let you know!

prine commented 9 years ago

Oukay, perfect. I also started replacing the UIView with a CALayer and I have successfully fixed the Back button problem, but the resizing problem still exists. Will create a Pullrequest when I have found a solution for the resizing problem.

stremblayiOS commented 8 years ago

All you have to do is add this at line 91 of UINavigationBar+Animation.swift

busy_loadingView?.userInteractionEnabled = false
gmertk commented 8 years ago

@stremblayiOS thank you!