ABCalendarPicker icon indicating copy to clipboard operation
ABCalendarPicker copied to clipboard

Pod not working correctly

Open tilowestermann opened this issue 11 years ago • 9 comments

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: Screen Shot 2013-04-01 at 1 51 56 PM

Hitting "Today" ([self.calendarPicker setDate:[NSDate date] andState:ABCalendarPickerStateDays animated:YES];) leads to the following: Screen Shot 2013-04-01 at 1 51 59 PM

Hitting "Today" again.. this seems to be almost "right", but there is still an empty row. Screen Shot 2013-04-01 at 1 52 03 PM

I hope this is enough to reproduce this bug.

tilowestermann avatar Apr 01 '13 11:04 tilowestermann

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 .

С уважением, Буков Антон.

k06a avatar Apr 01 '13 12:04 k06a

Thanks for the quick reply. Does this also happen when using ABCalendarPicker as a static library?

tilowestermann avatar Apr 01 '13 12:04 tilowestermann

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 .

С уважением, Буков Антон.

k06a avatar Apr 01 '13 14:04 k06a

I got the same problem when I created my test project with storyboard. No solution yet?

kevinsmbox avatar Jun 18 '13 08:06 kevinsmbox

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.

k06a avatar Jun 18 '13 15:06 k06a

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 avatar Jul 31 '13 13:07 GreatWiz

@GreatWiz do you know how to make this backward compatible with iOS 5 or maybe 4?

k06a avatar Aug 04 '13 14:08 k06a

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];

juanchristensen avatar Sep 08 '13 05:09 juanchristensen

if we allocate with initwith frame its working fine for me.. self.calendarPicker = [[ABCalendarPicker alloc] initWithFrame:CGRectMake(0, 0, 320, 240)];

SrivathsavaKB avatar Dec 17 '13 12:12 SrivathsavaKB