如何在swift3中显示日历中的未来日期

时间:2017-10-28 20:28:08

标签: ios swift

我正在使用DaySquare日历。

我有dateObjects数组。

我必须在日历中显示此日期,但我有理由:'无效月份:0'错误。

import UIKit
import Daysquare

class ViewController: UIViewController {
    var dateObjects = [Date]()
    var calendarFromDateArr2 = [String]()

    @IBOutlet var calendarView: DAYCalendarView!

    override func viewDidLoad() {
        super.viewDidLoad()

        calendarFromDateArr2 =  ["2017-10-30T07:41:00", "2017-10-30T11:23:00", "2017-10-30T11:48:00", "2017-11-10T00:00:00", "2017-11-13T19:43:00", "2017-12-01T00:00:00", "2017-12-31T00:00:00"]

        let dateFormatter = DateFormatter()
        dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
        dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
        dateObjects = calendarFromDateArr2.flatMap { dateFormatter.date(from: $0) }

        print(dateObjects)

        for date in dateObjects
        {
            self.calendarView.selectedDate = date
        }
    }
}

当我给出"返回"在这一行之后:

self.calendarView.selectedDate = date.

0 个答案:

没有答案