I am a beginner in writing iOS apps and am currently working on a calendar app using FSCalendar. I want my app to go to the next view controller whenever I tap on the selected day on the FSCalendar (to show details about events on the selected day) but I couldn't find a way to create a segue that connects from the selected day to the view controller.
If segue is the way to go in this case, how do I make one? But if segue isn't the way to do it, please give some suggestions of other possible solutions. Thank you in advance!
FSCalendar has a "did select date" delegate function. If you are looking at the Swift Storyboard Sample, it is called and prints a formatted date to the debug console. That's where you can trigger your segue.
Start by adding a "Detail" view controller class:
Add a view controller to the Storyboard with a couple labels, set its class to
DetailViewController, and connect the "Detail Label" to themyLabel@IBOutlet:Ctrl-Drag from the view controller icon at the top of the FSCalendar view controller to your new Detail View Controller, and select
Showfrom the popup menu:You'll see that a
seguehas been added. Select that segue and give it an identifier of "gotoDetail":In
InterfaceBuilderViewControllerclass, find this func:and add a
performSegueline at the end:still in
InterfaceBuilderViewControllerclass, find theprepare(for segue...func:and add this code at the end:
Run the app, select
Interface Builderfrom the table view, and select a date. Your new Detail controller should be pushed into view, and it should display your selected date.