A method to set the progress to 0 would be nice
Opened this issue · 8 comments
I'm using a flexBar in a view with two tableViews, and I have the following (self inflicted) issue — when I scroll down the first tableView, it collapses the bar. But when I switch to the second view, the bar is still collapsed, and can't be pulled down (see my video). Both of the scroll views delegates split to the flexBar, which actually seems to work fine except for this small thing. A simple fix would be a method I could call to un-collapse the flexBar when it switches (with an animation), which works fine for me. Thanks!
Thanks for the video explaining the issue. progress
is a readwrite property of BLKFlexibleHeightBar
, so you could just manually set that to 0.0 when appropriate.
You could also look at
/**
Snap to the specified progress position.
@param The progress position that the bar will snap to.
@param The UIScrollView whose offset will be adjusted during the snap.
*/
- (void)snapToProgress:(CGFloat)progress scrollView:(UIScrollView *)scrollView;
in BLKFlexibleHeightBarBehaviorDefiner
.
I'll look into snapToProgress. The problem with setting the progress is that it doesn't change it until the scroll view is scrolled again. Is that expected behavior?
Sent from my iPhone
On Apr 5, 2015, at 7:15 PM, Bryan Keller notifications@github.com wrote:
Thanks for the video explaining the issue. progress is a readwrite property of BLKFlexibleHeightBar, so you could just manually set that to 0.0 when appropriate.
You could also look at
/**
Snap to the specified progress position.
@param The progress position that the bar will snap to.
@param The UIScrollView whose offset will be adjusted during the snap.
*/
- (void)snapToProgress:(CGFloat)progress scrollView:(UIScrollView *)scrollView;
in BLKFlexibleHeightBarBehaviorDefiner.—
Reply to this email directly or view it on GitHub.
After setting the progress, you need to let the bar know that it needs to be re-laid out. Do this using
[myBar setNeedsLayout];
In hindsight, setting progress on the bar should automatically call
[self setNeedsLayout];
My next release will likely fix this.
So close to perfect! But setNeedsLayout doesn't animate. I'll try adding that myself. Unless there's a way to do that and I'm missing it?
Sent from my iPhone
On Apr 5, 2015, at 7:35 PM, Bryan Keller notifications@github.com wrote:
After setting the progress, you need to let the bar know that it needs to be re-laid out. Do this using
[myBar setNeedsLayout];
In hindsight, setting progress on the bar should automatically call[self setNeedsLayout];
My next release will likely fix this.—
Reply to this email directly or view it on GitHub.
Call
[myBar layoutIfNeeded]
right after. Let me know if that works!
Edit: It's worth noting that
- (void)snapToProgress:(CGFloat)progress scrollView:(UIScrollView *)scrollView;
Calls setNeedsLayout
and layoutIfNeeded
for you, so you can just put that call in a UIView animation block. If you pass your scrollView, it will adjust its position as well. Pick whichever solution works best for you!
Same as before. Thanks so much for looking into this!
Sent from my iPhone
On Apr 5, 2015, at 7:46 PM, Bryan Keller notifications@github.com wrote:
Call
[myBar layoutIfNeeded]
right after. Let me know if that works!—
Reply to this email directly or view it on GitHub.
In FacebookStyleViewController
from the demo project in the repo, I add this:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[UIView animateWithDuration:1.0 animations:^{
self.myCustomBar.progress = 1.0;
[self.myCustomBar setNeedsLayout];
[self.myCustomBar layoutIfNeeded];
}];
}
And it animates fine. What's different on your end?
Any update on your end?