Code Monkey home page Code Monkey logo

Comments (16)

alskipp avatar alskipp commented on September 27, 2024

Here is the code I've just tried in a UITableViewCell subclass:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.recordPercentageSlider = [ASValueTrackingSlider new];
        self.recordPercentageSlider.delegate = self;
        self.recordPercentageSlider.frame = CGRectMake(20.0, 45.0, CGRectGetWidth(self.frame) - 2.0 * 20.0, 31.0);
        self.recordPercentageSlider.font = [UIFont fontWithName:@"AvenirNext-Medium" size:15.0];
        self.recordPercentageSlider.tintColor = [UIColor redColor];
        self.recordPercentageSlider.autoAdjustTrackColor = NO;
        [self.recordPercentageSlider addTarget:self action:@selector(recordPercentageValueChanged) forControlEvents:UIControlEventValueChanged];
        [self.contentView addSubview:self.recordPercentageSlider];

        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setNumberStyle:NSNumberFormatterPercentStyle];
        [self.recordPercentageSlider setNumberFormatter:numberFormatter];
        self.recordPercentageSlider.popUpViewAnimatedColors = @[[UIColor orangeColor], [UIColor purpleColor]];
    }
    return self;
}

The colors animated as expected. I also tried setting up the slider in a table cell in the storyboard and setting the animated colors in awakeFromNib and it behaved as expected.

Could you offer anymore info to help me track down the problem. Could you also check the colors you set to make sure they are what you expected in the following line:

self.recordPercentageSlider.popUpViewAnimatedColors = @[[UIColor carbonColorWithAlpha:ZTAlphaLevelFull], [UIColor autumnColorWithAlpha:ZTAlphaLevelFull]];

from asvaluetrackingslider.

 avatar commented on September 27, 2024

Just copies the code snippet you posted, and it worked in one situation and not in the other.
The only major difference between the two situations that I could think could cause a problem is:
The one that didn't work was a cell part of a uitableviewcontroller from the storyboard and was initialized with initWithCoder
The other one was created in programmatically with initWithStyle:reuseIdentifier:

Nothing elaborate about the colors, only these:
The ZTAlphaLevelFull is 1.0
Carbon: return [UIColor colorWithRed:38/255.0 green:38/255.0 blue:38/255.0 alpha:alpha];
Autumn: return [UIColor colorWithRed:255/255.0 green:138/255.0 blue:9/255.0 alpha:alpha];

Any other info you need, just tell me and thanks again for your time

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hi @aj1310,
I've still not managed to reproduce this bug. I thought it might have something to do with using it in a tableview with a large number of cells. In that case the cells are reused when scrolling - I thought perhaps that might cause the problem, but I've just tried that and it worked correctly.

Does the animation work initially then fail to update after some action, or does it never work in this instance?
Are you able to post a sample project online that exhibits the bug?

from asvaluetrackingslider.

DisobedientMedia avatar DisobedientMedia commented on September 27, 2024

Hi, I'm not sure if this is 100% related, but I've just come here to log an issue about animation colour not working correctly - depending on the min, max values and the stop positions.

here's my code

    slider.minimumValue = 1.0;
    slider.maximumValue = 5.0;    
    [slider setPopUpViewAnimatedColors:@[
                                        [UIColor redColor],
                                        [UIColor yellowColor],
                                        [UIColor greenColor]
                                        ]
                         withPositions:@[
                                         @1.0,
                                         @2.5,
                                         @5.0]
     ];

This results in incorrect values being calculated in ASValueTrackingSlider keyTimesFromSliderPositions:, in this case instead of returning 3 values evenly spaced from 0.0 to 1.0 I get

[
0.5,
0.875,
1.5
]

This results in the green colour never being shown when the slider is at 5 - it's still yellow.

If I do the same but adjust the maximumValue to 10.0 the colors work more as expected, (but still not quite if you look at the keyTimes output).

    slider.minimumValue = 1.0;
    slider.maximumValue = 10.0;

    // red, yellow, green
   [slider setPopUpViewAnimatedColors:@[
                                        [UIColor redColor],
                                        [UIColor yellowColor],
                                        [UIColor greenColor]
                                        ]
                         withPositions:@[
                                         @1.0,
                                         @5.0,
                                         @10.0]
     ];

results in keyTimes of

[
0.2222222,
0.6666667,
1.222222
]

Happy to open new Issue, but thought it might be of use here.
Thanks

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hi @DisobedientMedia,
Thanks for the report. This is definitely a bug. Having a minimumValue above zero seems to cause the issue. By the way, if you just need the colors distributed evenly you don't need to set positions manually (obviously due to the bug, this isn't quite the case at the minute - whoops). I'll try and publish a fix ASAP.

Cheers,
Al

from asvaluetrackingslider.

DisobedientMedia avatar DisobedientMedia commented on September 27, 2024

Great, thanks. I tried the slider.popUpViewAnimatedColors = @[color1,color2,color3], but as you say, it didn't work as expected.

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hi @DisobedientMedia,
I've just published a bug fix branch, here: https://github.com/alskipp/ASValueTrackingSlider/tree/anim_fix
This should fix the issue you were experiencing. Could you try this branch and confirm if it works for you? I'll then merge it into master.

Cheers,
Al

from asvaluetrackingslider.

DisobedientMedia avatar DisobedientMedia commented on September 27, 2024

Thanks Al, works as expected now. Much appreciated.
cheers,
Robin

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hi @aj1310,
The issue you raised was back in May, so this could well be too late for you. However, if the slider that didn't animate correctly for you had a minimumValue greater than zero, it is very likely that this is the same bug. If you are still using the component then please try this fix to see if it solves the issue.

All the best,
Al

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hi Robin,
Thanks for confirming the fix and thanks for raising the issue. Your sample code really helped track down the problem, so it's much appreciated.

Please pass on my greetings to the glorious north,
Al

from asvaluetrackingslider.

Jack-s avatar Jack-s commented on September 27, 2024

Hi @alskipp
I think I'm encountering a related issue (if you prefer I can open a separate issue).

I'm using ASValueTrackingSlider in a UITableViewCell with a a few values being passed for the animation, when the initial value of the slider is 0 it works correctly however if I set a different initial value the popupview and slider still start from the first color passed in and as a result don't reach the last color in the animation.

For example I'm setting 5 colors like the following

[self.accuracySlider setPopUpViewAnimatedColors:@[
                                                      [UIColor redColor],
                                                      [UIColor orangeColor],
                                                      [UIColor purpleColor],
                                                      [UIColor blueColor],
                                                      [UIColor greenColor]]];

And I'm then setting the value of the slider (in tableView:cellForRowAtIndexPath)

self.accuracySlider.value = 10.0;

In this case the popupview and slider never reach the green color.

If however I defer setting the sliders value it works correctly

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), 
dispatch_get_main_queue(), ^{
           self.accuracySlider.value = 10.0;
        });

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hi @Jack-s
Thanks for reporting this. Could I ask a few questions: Is this issue occurring while using the latest release? Could you try your project with this branch https://github.com/alskipp/ASValueTrackingSlider/tree/popup_refactor, there have been significant internal changes, which may help.

I've been unable to reproduce the issue, which makes it very difficult to solve the problem you've been experiencing. Would it be at all possible to post a gist/send me a small example that demonstrates the issue? I'm very keen to give this bug a good squashing, but it's eluding me!

All the best,
Al

from asvaluetrackingslider.

Jack-s avatar Jack-s commented on September 27, 2024

@alskipp
The problem still appears in the linked branch.

I modified the example to reproduce the issue, here's a link to the project

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hi @Jack-s ,
Thanks for trying the other branch and for uploading the test project. I'll take a quick look and see if I can track down the issue. I'll have more time next week to investigate more deeply if needed. Hopefully, it'll be a simple fix : )

Al

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

Hmmm, I'm now seeing this issue occur quite frequently on Xcode 6 (beta 5). In Xcode 5, it only seemed to occur in a few edge cases. Will investigate further.

from asvaluetrackingslider.

alskipp avatar alskipp commented on September 27, 2024

These issues seem to have been resolved when using the latest Xcode release (6.3). I'll close the issue for now on the assumption that all is well crossed fingers.

from asvaluetrackingslider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.