NWCalendarView icon indicating copy to clipboard operation
NWCalendarView copied to clipboard

Defining constraints of calendar view

Open daisyramos317 opened this issue 9 years ago • 12 comments

Where do you define the constraints for the month/weekly view?

If you take a look here, Saturday is cut off. image

Also how can I set a selected date to stay selected? unless it's tapped twice to deselect in order to allow the user to select multiple dates that aren't consecutive. I noticed there is a delegate for NWCalendarDayViewDelegate, perhaps there?

Thanks! Great library by the way

daisyramos317 avatar Feb 29 '16 16:02 daisyramos317

I calculate the column widths here https://github.com/nbwar/NWCalendarView/blob/master/NWCalendar/NWCalendarMonthView.swift#L184

Are you using Autolayout to set the width and height of the calendar?

nbwar avatar Feb 29 '16 17:02 nbwar

Yes using Autolayout I set the constraints to (0, 64, 414, 383)

daisyramos317 avatar Feb 29 '16 19:02 daisyramos317

It sounds look an Autolayout issue. The reason saturday is not seen is because when the column widths are calculated the ViewController is larger so the columns are though to larger. Try creating the calendar by code and see if that fixes your problem.

nbwar avatar Feb 29 '16 20:02 nbwar

Ok I tried

var calendarView: NWCalendarView = NWCalendarView()

it looks like the calendar isn't populated

daisyramos317 avatar Feb 29 '16 20:02 daisyramos317

You have to call calendarView.createCalendar()

nbwar avatar Feb 29 '16 20:02 nbwar

Yes I have this as well

daisyramos317 avatar Feb 29 '16 20:02 daisyramos317

I would have to see more code to figure out the issue. Does the example work for you?

nbwar avatar Feb 29 '16 20:02 nbwar

This is how I've declared it programatically:

var calendarView: NWCalendarView = NWCalendarView() calendarView.frame = CGRectMake(0, 64, 414, 383) view.addSubview(calendarView)

The example works fine, it does seem to be an autolayout issue as I increased the width and height.

daisyramos317 avatar Feb 29 '16 21:02 daisyramos317

Actually I reverted back to using the calendar through IBOutlet and disabled autolayout for this view

calendarView.translatesAutoresizingMaskIntoConstraints = true

doesn't seem to solve it :(

daisyramos317 avatar Feb 29 '16 21:02 daisyramos317

I too was wondering how to fix the auto layout issue,

daisyramos317, did you manage to fix this, if so can you please share?

ghost avatar Mar 09 '16 19:03 ghost

Can you give me steps to reproduce or a sample project with the bugs you are experiencing?

nbwar avatar Mar 09 '16 19:03 nbwar