k06a / ABCalendarPicker

Fully configurable iOS calendar UI component with multiple layouts and smooth animations.
MIT License
710 stars 119 forks source link

ABCalendarPickerDelegate - calendarPicker:shouldSetState:fromState #7

Closed RobTerry-Cistec closed 11 years ago

RobTerry-Cistec commented 11 years ago

Hi,

I was attempting to use your framework for an upcoming app I'm working on. But I wanted to lock the app down to one particular state. However after some head scratching and debugging I found that your delegate method for 'calendarPicker:shouldSetState:fromState:' was never re-enabling user interaction if any of the states were disallowed.

So I've manually made a change in my copy of your app code as follows:

Current live code:

    if ([(id)self.delegate respondsToSelector:@selector(calendarPicker:shouldSetState:fromState:)]
        && ![self.delegate calendarPicker:self shouldSetState:toState fromState:fromState])
    {
        return;
    }

My fix:

    if ([(id)self.delegate respondsToSelector:@selector(calendarPicker:shouldSetState:fromState:)]
        && ![self.delegate calendarPicker:self shouldSetState:toState fromState:fromState])
    {
        self.userInteractionEnabled = YES;
        return;
    }

Figured that some others may have been stuck with this.

Regards, Rob

k06a commented 11 years ago

Thank you!

@a2 fixed this bug in this commit in his fork - https://github.com/a2/ABCalendarPicker/commit/6c01d55f678a2976ba3016649627eaaf1b335b5b I'll merge this fork soon...

k06a commented 11 years ago

@RobTerry-Cistec if you would like to participate in any project development manually - you should fork repository, push own commits to your fork and then pull request to original repository.

RobTerry-Cistec commented 11 years ago

Hi Anton,

Thanks, I may just do that… The other thing that I did notice is that it didn't seem to take into account the fact that I was setting the maximum number of dots (in my test I was setting it to three but the app went on until it was displaying six). But I got around that in my own code by using MIN() in the call to

Regards, Rob

Rob Terry | Technical Director e: rob.terry@cistec.co.uk t: 0845 475 7750

On 1 Mar 2013, at 16:27, Anton Bukov notifications@github.com wrote:

@RobTerry-Cistec if you would like to participate in any project development manually - you should fork repository, push own commits to your fork and then pull request to original repository.

— Reply to this email directly or view it on GitHub.

k06a commented 11 years ago

You should use this to truncate max visible dots:

[(id)self.calendarPicker.styleProvider setMaxNumberOfDots:2];

Because style provider is responsible for cell drawing... I'll remove maxNumberOfDots property from ABCalendarPicker class - it is rudiment.