ABCalendarPicker
ABCalendarPicker copied to clipboard
Pod not working correctly
I finally got some time to try ABCalendarPicker (the CocoaPods version). However, I'm experiencing something that may not be intended behavior. I tried a minimalistic approach, just like the one in the demo. As screenshots may tell more than words:
Right after starting the App:
Hitting "Today" ([self.calendarPicker setDate:[NSDate date] andState:ABCalendarPickerStateDays animated:YES];) leads to the following:
Hitting "Today" again.. this seems to be almost "right", but there is still an empty row.
I hope this is enough to reproduce this bug.
I know how to avoid it, but don't know how to fix - do not use autolayout.
I finally got some time to try ABCalendarPicker (the CocoaPods version). However, I'm experiencing something that may not be intended behavior. I tried a minimalistic approach, just like the one in the demo. As screenshots may tell more than words:
Right after starting the App: [image: Screen Shot 2013-04-01 at 1 51 56 PM]https://f.cloud.github.com/assets/854017/323640/c55e6e9a-9ac2-11e2-9dec-432bccf4a8da.png
Hitting "Today" ([self.calendarPicker setDate:[NSDate date] andState:ABCalendarPickerStateDays animated:YES];) leads to the following: [image: Screen Shot 2013-04-01 at 1 51 59 PM]https://f.cloud.github.com/assets/854017/323639/c5528094-9ac2-11e2-8f76-cc118c897306.png
Hitting "Today" again.. this seems to be almost "right", but there is still an empty row. [image: Screen Shot 2013-04-01 at 1 52 03 PM]https://f.cloud.github.com/assets/854017/323638/c551ee0e-9ac2-11e2-99b3-0b2d372b2163.png
I hope this is enough to reproduce this bug.
— Reply to this email directly or view it on GitHubhttps://github.com/k06a/ABCalendarPicker/issues/14 .
С уважением, Буков Антон.
Thanks for the quick reply. Does this also happen when using ABCalendarPicker as a static library?
Yes, same problem also happen. Contribute if you'll find a way to fix it.
Thanks for the quick reply. Does this also happen when using ABCalendarPicker as a static library?
— Reply to this email directly or view it on GitHubhttps://github.com/k06a/ABCalendarPicker/issues/14#issuecomment-15713480 .
С уважением, Буков Антон.
I got the same problem when I created my test project with storyboard. No solution yet?
Just turn off autolayout in storyboard or help us to fix another way :)
I got the same problem when I created my test project with storyboard. No solution yet?
— Reply to this email directly or view it on GitHub.
Check your constraints. I used it (not via pods, but a git submodule, and without storyboard). Added a height constraint on the whole ABCalendarView, and I change the constant value of the constraint every time the delegate reports a height change, and everything works fine.
@GreatWiz do you know how to make this backward compatible with iOS 5 or maybe 4?
This issue happens because the ABCalendarPicker UIView is instantiated before the actual bounds of the view are set by autolayout (all the bounds are set once viewDidLayoutSubviews executes in your viewcontroller).
Just to trace out the issue: init -> initWithDefaultProviders -> initWithStyleProvider..... -> setState -> changeStateTo In the changeStateTo method is where things get messed up. if (self.gradientBar == nil)
if (self.mainTileView == nil)
[self updateButtonsForProvider:provider andState:toState];
[self updateColumnNamesForProvider:provider];
[self updateArrowsForProvider:provider];
[self updateTitleForProvider:provider];
Basically, both the gradientBar and the mainTileView get setup with incorrect sizes/positions.
The wise thing to do, would be to reimplement layoutSubviews (without calling [super layoutSubviews] to avoid autolayout messing with things) and check if the bounds have changed, and if so, update everything.
Alternatively, just override layoutSubviews in ABCalendarPicker.m with an empty implementation (so that autolayout doesn't attempt to layout the controls inside that view), and instead of adding the ABCalendarPicker view with IB, add it programmatically in your view controller by using the initWithFrame constructor, that way the picker knows it's size and is able to setup everything correctly the first time.
self.calendarPicker = [[ABCalendarPicker alloc] initWithFrame:CGRectMake(0, 0, 320, 240)];
self.calendarPicker.delegate = self;
self.calendarPicker.dataSource = self;
[self.view addSubview:self.calendarPicker];
if we allocate with initwith frame its working fine for me.. self.calendarPicker = [[ABCalendarPicker alloc] initWithFrame:CGRectMake(0, 0, 320, 240)];