Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added workaround for a bug in UIDatePicker in count down mode. #105

Merged
merged 24 commits into from
Dec 3, 2014
Merged

Added workaround for a bug in UIDatePicker in count down mode. #105

merged 24 commits into from
Dec 3, 2014

Conversation

tomaskraina
Copy link

A solution proposed by Positron on http://stackoverflow.com/a/20204317/1161723

This fixes #104

@skywinder
Copy link
Owner

Thanks for contribution.
Your commit broke a couple tests in the project https://travis-ci.org/skywinder/ActionSheetPicker-3.0/builds/42542107
I need to find out why the tests are failing now.

@tomaskraina
Copy link
Author

Is there any way I could help with that?

@skywinder
Copy link
Owner

You can look at the failing tests inside the project:

-[ActionSheetDatePickerTestCase testPickerCountDownTimerModeValueWithBlock]
-[ActionSheetDatePickerTestCase testPickerCountDownTimerModeValueWithSelector]

If you have idea, why it fails now - please, let me know.

@skywinder
Copy link
Owner

It's really strange behaviour (so, we need do to async assignment in main thread from main thread).

So, nevertheless - my test start to failing after that fix.

It happens, because that tests execute pressDoneButton immediately from main thread - and when you wrap it to async the value doesn't change in that short period.
I suppose it's very rare case, because user can't press the button instantly, but it is a potential bug.

As workaround - It's possible to not replace my assignment with yours async, but add it after. i.e. do the same work twice. In that case tests work as expected.

I believe thinks there is should be a better solution.

@skywinder
Copy link
Owner

There is 2 solutions that I found:

  1. add that code instead of yours replace:
 datePicker.countDownDuration = self.countDownDuration;
 dispatch_async(dispatch_get_main_queue(), ^{
 datePicker.countDownDuration = self.countDownDuration;
 });
  1. Run test with fake delay:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [NSThread sleepForTimeInterval:0.5f];
        dispatch_async(dispatch_get_main_queue(), ^{
            [_actionSheetDatePicker pressDoneButton];
        });
    });

@skywinder
Copy link
Owner

Please add to that pull-request my fixes from tomaskraina-master branch and I will ready to merge it.

@tomaskraina
Copy link
Author

Is it okay like this?

@skywinder
Copy link
Owner

Perfect! 👍

skywinder added a commit that referenced this pull request Dec 3, 2014
Added workaround for a bug in UIDatePicker in count down mode.
@skywinder skywinder merged commit 8a8eec9 into skywinder:master Dec 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants