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

CKCalendarView appearing behind iOS 7 status bar #37

Closed
ed-parry opened this issue Feb 12, 2014 · 21 comments
Closed

CKCalendarView appearing behind iOS 7 status bar #37

ed-parry opened this issue Feb 12, 2014 · 21 comments
Assignees
Labels

Comments

@ed-parry
Copy link

This is a similar issue to having a UITableView on a UIView in iOS 7, where the UITableView starts too high and is behind the status bar. When I put a CKCalendarView on a UIView, the calendar starts behind the status bar, too. I can't seem to figure out a way of pushing it down by 64-pixels to be in the correct place. Is there something I'm missing?

CKCalendarView Issue

@MosheBerman
Copy link
Owner

This is caused because of a change in iOS 7's full screen paradigm. I thought I had fixed this, but I'll take a look in a particular project that uses it and see if I can find the fix I applied there. Give me a few minutes please.

@MosheBerman
Copy link
Owner

Are you using CKCalendarView or CKCalendarViewController?

@ed-parry
Copy link
Author

I'm using CKCalendarView on a standard UIView, which has both a NavigationController and TabViewController on it. Thanks for the reply!

@MosheBerman
Copy link
Owner

Looking now. It's been a while...

@MosheBerman
Copy link
Owner

Ah, so I see what's going on here. If you poke around inside of CKCalendarView.m, you'll find that the setters for the calendar view's frame are overridden so that the calendar view is stuck to the top of the screen. (Look at setFrame:, setFrame:animated: and_rectForDisplayMode:`.)

In iOS 6, this wasn't an issue, because the navigation bar occupied the top of the display. For iOS 7, I made some changes to the CKCalendarViewController class and all was well... Or so I thought. It seems I forgot this case.

Solutions I'm considering:

  • Changing the way frames are set, so that the calendar view has an "origin" property. The setFrame: and related methods would then query the origin when building a frame.
  • Emulating UIPickerView and allowing you to set whatever frame you want, but ignoring the height and width of the frame. This is similar to the other option, except the API is perhaps simpler and arguably more correct for emulating Apple.

What do you think?

@MosheBerman
Copy link
Owner

PS: As a short term hack, try setting the center property and see what happens.

@ed-parry
Copy link
Author

I'm sorry, I'm relatively new to Objective-C, so I'm not positive on the best long-term resolution for it. However, the second solution of emulating the UIPickerView strikes me as the best option of the two.

Setting the center property didn't have any effect on it for me. As a solution for myself now, I pushed the main frame down by 64-pixels, in the - (void)layoutSubviewsAnimated:(BOOL)animated method (line 243 of CKCalendarView.m):

- (void)layoutSubviewsAnimated:(BOOL)animated
{
    /*  Enforce view dimensions appropriate for given mode */
    CGRect frame = CGRectMake(0, 64, 0, 0); //[self _rectForDisplayMode:[self displayMode]];
    //CGPoint origin = [self frame].origin;
    //frame.origin = origin;
    [self setFrame:frame animated:animated];

    ...
}

@ed-parry
Copy link
Author

...although my solution also requires you to add 64-pixels to the tableFrame, done on line 272 of CKCalendarView.m:

tableFrame.origin.y += [self frame].size.height + 64;

@MosheBerman
Copy link
Owner

Interesting... That's right, the tableFrame needs to be shifted. Don't forget to remove that same value from the bottom though. (The height property may be 64 pixels too long.)

As general practice, you're not supposed to hard code values, but instead use a dynamically calculated value. As I said, I really need to get working on this, but thanks for pointing out the issues and your tentative solution.

@MosheBerman MosheBerman self-assigned this Feb 12, 2014
@ed-parry
Copy link
Author

No problem - thanks for pointing me in the right direction!

@nagi
Copy link

nagi commented Mar 21, 2014

Setting the bar to Opaque fixed it for me:

screen shot 2014-03-21 at 11 24 19

@FlorianBasso
Copy link

I fixed this issue by setting my navigationBar.translucent to NO.

@MosheBerman
Copy link
Owner

That makes sense, because iOS 7 will stretch views to the full height of the screen if the navigation bar is translucent. If you want to keep a translucent bar, look at the preceding discussion, for now.

@MosheBerman
Copy link
Owner

The correct fix is to use the topLayoutGuide, to offset the calendar, iirc.

@4tress
Copy link

4tress commented Jul 30, 2014

The correct fix is to count tableFrame.origin.y like this: tableFrame.origin.y += ([self frame].size.height + [self frame].origin.y);, according not only to the calendar frame height, but also its y position delta.

@MosheBerman
Copy link
Owner

@4tress, Ah, for the table offset, yes. I'd suggest using the CGGeometry macros, though. (CGRectGetMaxY(self.calendar.frame) etc...)

I've got my hands full at the moment, but I do intend to work on a fix for this.

@MosheBerman
Copy link
Owner

How are we all doing with this?

@griffind
Copy link

griffind commented Apr 7, 2015

I fixed this by adding

calendar.frame = CGRectOffset(self.view.frame, 0.0, 65.0);

to the viewDidLoad

@bendparker
Copy link

I'm still experiencing it...using griffind's solution for now.

@bendparker
Copy link

Would be nice to have it fixed, but the work around is okay for now.

Also--I can't seem to initiate an instance of class CKCalendarViewControllerInternal, do I need to import another file for that?

@MosheBerman
Copy link
Owner

The internal view controller needs to be imported separately. It's imported in the public version of the view controller, which subclasses UINavigationController instead of UIViewController. It's otherwise the same thing.

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

No branches or pull requests

7 participants