Skip to content
New issue

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

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

Already on GitHub? # to your account

Pod not working correctly #14

Open
tilowestermann opened this issue Apr 1, 2013 · 9 comments
Open

Pod not working correctly #14

tilowestermann opened this issue Apr 1, 2013 · 9 comments

Comments

@tilowestermann
Copy link

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.

@k06a
Copy link
Owner

k06a commented Apr 1, 2013

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//issues/14
.

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

@tilowestermann
Copy link
Author

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

@k06a
Copy link
Owner

k06a commented Apr 1, 2013

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//issues/14#issuecomment-15713480
.

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

@kevinsmbox
Copy link

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

@k06a
Copy link
Owner

k06a commented Jun 18, 2013

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.

@GreatWiz
Copy link

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.

@k06a
Copy link
Owner

k06a commented Aug 4, 2013

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

@juanchristensen
Copy link

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

@SrivathsavaKB
Copy link

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants