Open fukemy opened 1 year ago
A brief bug description.
Stack trace. no problem found
Integration method.(cocoapods)
(cocoapods)
Device modal and iOS version. cocoapods
Xcode version. 14
FSCalendar version. lasted
I have set toDay date in viewDidload, then called reloadData(). but not working
Here is my code:
// // BDatePicker.swift // Bindr // // Created by James Kauten on 12/17/16. // Copyright © 2016 Kauten Creations. All rights reserved. // import UIKit import PopupDialog /// Combine the day, month, year from date with the hours, minutes, seconds, of /// time /// - parameters: /// - date: the date to get the day month year from /// - time: the date to get the hours minutes seconds from func combine(date: Date, time: Date) -> Date { let cal = Calendar.current var dateComponents = cal.dateComponents([.day, .month, .year], from: date) let timeComponents = cal.dateComponents([.hour, .minute], from: time) dateComponents.hour = timeComponents.hour dateComponents.minute = timeComponents.minute dateComponents.second = 0 return cal.date(from: dateComponents)! } /// A class to select a date a time with prettier UI public class UIPopupDatePicker: UIViewController { /// the popup that this picker is contained in var popup: PopupDialog! /// Handle a press to the clear button @IBAction func clearPressed() { if let completion = handler { completion(nil) } popup.dismiss(animated: true, completion: nil) } /// the header label @IBOutlet weak var header: UILabel! /// the text on the header label public var headerText: String? { get { return header.text } set { header.text = newValue } } /// Handle a press to the 'today' button @IBAction func todayPressed() { date = .today5min } /// the day selection agent @IBOutlet var calendar: FSCalendar! { didSet { let hvnl = "HelveticaNeue-Light" calendar.appearance.headerTitleFont = UIFont(name: hvnl, size: 12.0)! calendar.appearance.weekdayFont = UIFont(name: hvnl, size: 18.0)! } } /// the time selection agent @IBOutlet var timePicker: UIDatePicker! { didSet { // try to make the two ugly lines invisible on the picker view if timePicker.subviews.count >= 1 { if timePicker.subviews[0].subviews.count >= 2 { timePicker.subviews[0].subviews[1].isHidden = true timePicker.subviews[0].subviews[2].isHidden = true } } } } /// a constraint determining if the time picker should be used @IBOutlet weak private var pickerHeight: NSLayoutConstraint! /// A boolean attribute determining whether the time picker is enabled public var isPickerEnabled: Bool { get { return pickerHeight.constant == 61 } set { if newValue { pickerHeight.constant = 61 } else { pickerHeight.constant = 0 } } } /// the current date public var date: Date { set { calendar.select(newValue) timePicker.setDate(newValue, animated: true) } get { return combine(date: calendar.selectedDate!, time: timePicker.date) } } /// Dismiss the view controller with no changes made @IBAction func cancelPressed() { popup.dismiss(animated: true, completion: nil) } /// Handle a press to the done button @IBAction func donePressed() { popup.dismiss(animated: true, completion: nil) handler?(date) } /// Handles 'saving' var handler: ((Date?)->Void)? /// Setup the view after it's loaded into memory override public func viewDidLoad() { super.viewDidLoad() todayPressed() } /// Display a new date picker on top of an existing view controller /// - parameters: /// - viewController: the view controller to present on top of /// - date: the date to display /// - block: the function to handle completion public class func show(on viewController: UIViewController, with date: Date?=nil, block handler: @escaping ((Date?)->Void)) -> UIPopupDatePicker { // load the view from the storyboard let name = String(describing: classForCoder()) let bundle = Bundle(for: UIPopupDatePicker.self) let storyboard: UIStoryboard = UIStoryboard(name: name, bundle: bundle) let vc = storyboard.instantiateInitialViewController() let picker = vc as! UIPopupDatePicker // create the popup let popup = PopupDialog.init(viewController: picker, tapGestureDismissal: false) picker.popup = popup picker.handler = handler if let _date = date { picker.date = _date.roundedAbout5Min } if let calendar = picker.calendar{ calendar.reloadData() } // present the view controller viewController.present(popup, animated: true, completion: nil) // return the picker for further config return picker } }
Same here
The following informations are requested in a bug report
A brief bug description.
Stack trace. no problem found
Integration method.
(cocoapods)
Device modal and iOS version. cocoapods
Xcode version. 14
FSCalendar version. lasted
I have set toDay date in viewDidload, then called reloadData(). but not working
Here is my code: