jivesoftware / PDTSimpleCalendar

A simple Calendar / Date Picker for iOS using UICollectionView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unwind Segue

rustymagnet3000 opened this issue · comments

hi all,

I have implemented PDTSimpleCalender in Swift. I am happy with the results. My last step is getting the calender to "unwind" when a user selects a date.

My unwind segues work beautifully throughout my app. I double-checked with UIViewControllers and all worked great. But every time I try with my PDT class (which is a Collection View Controller) I get "can't find ID". Am I stumbling into an inheritance problem?

import UIKit

class customPDTCollectionViewController: PDTSimpleCalendarViewController,
PDTSimpleCalendarViewDelegate {

override func viewDidLoad() {
    super.viewDidLoad()

    // initialize my calender
    self.delegate = self
    self.firstDate = NSDate()
    self.calendar = NSCalendar.currentCalendar()
}

func simpleCalendarViewController(controller: PDTSimpleCalendarViewController!, didSelectDate date: NSDate!) {
    println("date selected is \(date) ")
//   self.performSegueWithIdentifier("unwindID", sender: self)

}

func simpleCalendarViewController(controller: PDTSimpleCalendarViewController!, shouldUseCustomColorsForDate date: NSDate!) -> Bool {
    return true
}

func simpleCalendarViewController(controller: PDTSimpleCalendarViewController!, circleColorForDate date: NSDate!) -> UIColor! {
    return UIColor(red: 0/255, green: 181/255, blue: 229/255, alpha: 1.0)
}

func simpleCalendarViewController(controller: PDTSimpleCalendarViewController!, textColorForDate date: NSDate!) -> UIColor! {
    return UIColor.whiteColor()
}

}

After too many hours of investigation, seems I have some issue with the "self". The value of self inside the didSelectDate function is bil. Any tips to fix are warmly received.

commented

Sorry @youdy3000 I never really used Storyboard.
If self == nil, you probably don't retain your controller (although that sounds weird, cause you would have tons of other issues if that was the case).
Have you tried running your app with NSZombies enabled?

Hi @jmig, thank you so much for responding. Good idea on the NSZombies. It did not work for me but I have closed the issue. The background is:

I could not get my PDT Simple Calender Select Date then to invoke my Unwind Segue. This is a shame as the unWind Segue is so quick and easy to implement (< 5minutes effort).

After a long battle, my workaround was to get the PDT Simple Calender View Controller passing data to the View Controller [that invoked the calender] using a Closure. PDT Simple Calender View Controller is dismissed using the old faithful Dismiss ViewController.

The solution is not elegant. But I was finally able to find a use for a Closure. My inspiration on the Closure was from this article.

http://stackoverflow.com/questions/24318480/passing-data-in-swift