Fscalendar: How to Add Prev / Next button for swap month in FSCalendar

Created on 5 Apr 2016  Â·  13Comments  Â·  Source: WenchaoD/FSCalendar

Most helpful comment

Hi,
The solution is here...

let _calendar = Calendar.current
var dateComponents = DateComponents()
dateComponents.month = 1 // For next button
dateComponents.month = -1 // For prev button
self.currentPage = _calendar.date(byAdding: dateComponents, to: self.currentPage!)

self.calendar.setCurrentPage(self.currentPage!, animated: true)// calender is object of FSCalendar

Thanks.

All 13 comments

I've add an example to show how to use prev-next buttons to change month. Please download and see the example.

1
2

No description for Previous and next button.
Please provide the description for that.
Thanks.

Thanks!!!

On Tue, Jul 18, 2017 at 6:22 AM, NuzhatPeerbits notifications@github.com
wrote:

No description for Previous and next button.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/WenchaoD/FSCalendar/issues/252#issuecomment-316061817,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARbmqMDofMfkqeAFaLqLeu8o_-zMfUN3ks5sPLGcgaJpZM4H_vlZ
.

Hi,
The solution is here...

let _calendar = Calendar.current
var dateComponents = DateComponents()
dateComponents.month = 1 // For next button
dateComponents.month = -1 // For prev button
self.currentPage = _calendar.date(byAdding: dateComponents, to: self.currentPage!)

self.calendar.setCurrentPage(self.currentPage!, animated: true)// calender is object of FSCalendar

Thanks.

Yup , its working

please where and how can I download this particular EXAMPLE that includes the previous and next buttons. thanks

Thank u so much

Thanks Nuzhat...

For anyone having issues with @NuzhatPeerbits brief explanation here a little more code to explain his idea:

```
@IBOutlet weak var calendarView: FSCalendar!

private var currentPage: Date?

private lazy var today: Date = {
return Date()
}()

@IBAction func monthForthButtonPressed(_ sender: Any) {

self.moveCurrentPage(moveUp: true)

}

@IBAction func monthBackButtonPressed(_ sender: Any) {

self.moveCurrentPage(moveUp: false)

}

private func moveCurrentPage(moveUp: Bool) {

let calendar = Calendar.current
var dateComponents = DateComponents()
dateComponents.month = moveUp ? 1 : -1

self.currentPage = calendar.date(byAdding: dateComponents, to: self.currentPage ?? self.today)
self.calendarView.setCurrentPage(self.currentPage!, animated: true)

}
````

where can i download this previous next month sample. can get any link ?

You can take 2 buttons on that view and use below code for the action.
Below code is in swift 3.2 as it was my old project. You can update it in
swift 4.2.

@IBAction func btnLAction(_ sender: Any)

{

    dateComponents.month = -1 // previous month



    self.currentPage = _calendar.date(byAdding: dateComponents, to: self

.currentPage!)

    self.calendar.setCurrentPage(self.currentPage!, animated: true)

}



@IBAction func btnRAction(_ sender: Any)

{

    dateComponents.month = 1 // next month



    self.currentPage = _calendar.date(byAdding: dateComponents, to: self

.currentPage!)

    self.calendar.setCurrentPage(self.currentPage!, animated: true)

}

On Mon, Nov 5, 2018 at 4:09 PM KimTe93 notifications@github.com wrote:

where can i download this previous next month sample. can get any link ?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/WenchaoD/FSCalendar/issues/252#issuecomment-435829680,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ac3JlSru-gPXFaHB3I0_THo32WdAtgIPks5usBVqgaJpZM4H_vlZ
.

--

Regards,Nuzhat ShaikhiOS Developer[image: Peerbits Logo]
https://www.peerbits.com/

[image: Social Icon] https://www.facebook.com/peerbits [image: Social
Icon] https://twitter.com/Peerbits [image: Social Icon]
https://www.linkedin.com/company/peerbits [image: Social Icon]
https://www.behance.net/peerbits

where can I find the code for Prev / Next button

It is customised... Original Source code does not have this code. The code
is already provided in my above message.

On Sat, Jan 5, 2019 at 7:43 PM PramodShukla10 notifications@github.com
wrote:

where can I find the code for Prev / Next button

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/WenchaoD/FSCalendar/issues/252#issuecomment-451659038,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ac3JlYALGrPOXtHw3zetOTfLXddWLjAeks5vALL2gaJpZM4H_vlZ
.

--

Regards,Nuzhat ShaikhiOS Developer[image: Peerbits Logo]
https://www.peerbits.com/

[image: Social Icon] https://www.facebook.com/peerbits [image: Social
Icon] https://twitter.com/Peerbits [image: Social Icon]
https://www.linkedin.com/company/peerbits [image: Social Icon]
https://www.behance.net/peerbits

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adavan2107 picture adavan2107  Â·  5Comments

StanleySathler picture StanleySathler  Â·  5Comments

rintoandrews90 picture rintoandrews90  Â·  4Comments

bizibizi picture bizibizi  Â·  3Comments

shilpashreemayigaiah picture shilpashreemayigaiah  Â·  3Comments