DSLCalendarView
DSLCalendarView copied to clipboard
iPhone 6/6 Plus calendar width
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.
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.
Hello, I have the same problem, did you manage to solve in some way? thanks so much
Either center it or use a different date control
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):
@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!
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.
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 .
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?
Sorry about that. Grabbed the wrong folder. Try it again. Link has been updated.
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.
add -Prefix.pch file
#define WINGUP 1 //iPhone 6/6 Plus calendar
and check it..
This might helps you :)
Yes..it work like a charm Thanks appreciate you.
@markkrenek I cleaned up the deprecated methods and imported into Swift Project:
https://github.com/ericcgu/DSLCalendarViewRedux