DSLCalendarView icon indicating copy to clipboard operation
DSLCalendarView copied to clipboard

iPhone 6/6 Plus calendar width

Open johnqh opened this issue 10 years ago • 13 comments

See screenshot. The width is fixed at 320 and does not adjust to the width.

I think the proper way is to use whatever width the view has, and calculate the width of each date accordingly.

ios simulator screen shot sep 11 2014 3 19 59 pm

johnqh avatar Sep 16 '14 22:09 johnqh

Additional notes:

The issue is that the view is created from storyboard with width of 320. The controller's view is then auto resized to the width of the screen, but there is no auto constraint, so the calendar view stayed 320.

johnqh avatar Sep 16 '14 23:09 johnqh

Hello, I have the same problem, did you manage to solve in some way? thanks so much

FabioDev84 avatar Oct 22 '14 09:10 FabioDev84

Either center it or use a different date control

johnqh avatar Oct 22 '14 16:10 johnqh

I modified the code to support any width screen and device rotation. There were quite a few changes but not really difficult.

  • In DSLCalendarView, the autoresizingMask for monthContainerView and monthContainerViewContentView are set to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin. The frame for monthSelectorView is set to the width of the calendar view. The autoresizingMask for each DSLCalendarMonthView in cachedOrCreatedMonthViewForMonth is set to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin. Implemented layoutSubviews so that it can call positionViewsForMonth.
  • For DSLCalendarMonthView, I eliminated the widthsCache (since it calculated the column widths only once instead of dynamically). I implemented layoutSubviews to resize the day views to fit the view width. layoutSubviews uses essentially the same code as createDayViews but uses the current view width.
  • For DSLCalendarDayView, switched to using a UILabel and UIImageView instead of drawRect. (This one may not be necessary.)
  • For DSLCalendarMonthSelectorView, I layout the day labels at runtime (via layoutSubviews) to spread them evenly across the view.
  • For DSLCalendarMonthSelectorView's nib, the resizing struts for the arrows and top label were updated so they respond to the view changing size.

The results was this (along with some other cosmetic changes):

ios simulator screen shot feb 11 2015 7 05 36 am

markkrenek avatar Feb 11 '15 13:02 markkrenek

@markkrenek Any chance you can share that code? I'm running into exactly this issue but would prefer not to have to reinvent the wheel on all these changes. The list will help I'm sure, but an updated set of code would be even better. Thanks!

dgable64 avatar Feb 18 '15 21:02 dgable64

You can grab my changes here - https://www.dropbox.com/s/6sokynlswgf1g75/DSLCalendarView-VariableWidth.zip?dl=0

I don't have the bandwidth right now to clean it up to be suitable for a pull request.

markkrenek avatar Feb 19 '15 14:02 markkrenek

Thanks much! On Feb 19, 2015 9:23 AM, "Mark Krenek" [email protected] wrote:

You can grab my changes here - https://www.dropbox.com/s/6sokynlswgf1g75/DSLCalendarView-VariableWidth.zip?dl=0

I don't have the bandwidth right now to clean it up to be suitable for a pull request.

— Reply to this email directly or view it on GitHub https://github.com/PeteC/DSLCalendarView/issues/35#issuecomment-75059259 .

dgable64 avatar Feb 19 '15 14:02 dgable64

I'm sorry, but the code in that dropbox link appears to be the original DSLCalendarView code without your changes. I can't find any WINGUP, layoutSubviews or any of the other changes mentioned in your notes. Is it possible you uploaded the wrong version?

dgable64 avatar Feb 19 '15 15:02 dgable64

Sorry about that. Grabbed the wrong folder. Try it again. Link has been updated.

markkrenek avatar Feb 19 '15 15:02 markkrenek

Hi..I download the files form dropbox but still I'm facing same problem. And yes I did try to do with the comments in the Notes files too but no success still it not resizing View. I don't know why...? Can you please help me to celebrate.

rahulshirphule avatar Apr 02 '15 13:04 rahulshirphule

add -Prefix.pch file

#define WINGUP 1 //iPhone 6/6 Plus calendar

and check it..

This might helps you :)

Yuyutsu avatar Apr 03 '15 10:04 Yuyutsu

Yes..it work like a charm Thanks appreciate you.

rahulshirphule avatar Apr 03 '15 11:04 rahulshirphule

@markkrenek I cleaned up the deprecated methods and imported into Swift Project:

https://github.com/ericcgu/DSLCalendarViewRedux

ericcgu avatar May 08 '15 14:05 ericcgu