1

I have been trying to change the tableview cell size when i change my FSCalendar scope from week to month or vice versa. This is working fine with calender.scope = .week and contents are displaying correctly as required but the bounds of the calendar is not getting updated hence my cell size doesn't change it's height.

I did following for achieving my goal when i change my scope and reload the calendar.

func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
    self.calenderView.frame.size.height = bounds.height
}

My Calendar View exits in the tableview cell and when the calendar changes it's scope, the cell size should also change but now it's not working.

Please help me.

Vikash Sinha
  • 869
  • 1
  • 7
  • 21

1 Answers1

0

Try this code

var height: CGFloat?

func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
    self.height = bounds.height
    self.calenderView.frame.size.height = bounds.height
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    // Here you can return specify the height of the cell.
    return height
}

What this does is that you will set the same height for the tableviewcell as well as for the calenderview. If you want to have multiple cells in the horizontal axsis, then consider using a collectionview.

Therefore we do not have to specify the width for the tableVieCell.

What we do is that we stor an optional height value inside the class and then set it when the boundingRectWillChange method gets called.

Hope this answer helps you and please let me know if you have any problems!