こんにちは私は次の応答があります
json: {
"status" : "success",
"data" : {
"classes" : {
"SUNDAY" : [
{
"latitude" : 32.3844785674545,
"uploads" : "https:\/\/xxxxx\/Uploads\/Class\/swimming.png",
"location" : "dubai",
"id" : 3,
"startDate" : "04-08-2018",
"endDate" : "05-08-2018",
"description" : "Basic Swimming Tactics for women trained by women.",
"title" : "Swimming Class",
"endTime" : "05:20",
"longitude" : 23.465767967087778,
"startTime" : "03:10",
"subTitle" : "Basic Swimming Tactics"
}
],
"WEDNESDAY" : [
],
"THURSDAY" : [
],
特定の日を手動で呼び出すことにより、テーブルビューでデータを既にフェッチしました。
以下のように 。
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return tableViewImageArray.count
return classes.count
}
// Table View Delegates
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let tCell = tableView.dequeueReusableCell(withIdentifier: "schedulesCell", for: indexPath) as! schedulesTVCell
// tCell.classThumb.image = tableViewImageArray[indexPath.row]
// tCell.classTitle.text = classNameArray[indexPath.row]
let allClasses = classes[indexPath.row]
tCell.classTitle.text = allClasses.title
tCell.classDesc.text = allClasses.description
tCell.classLocation.text = allClasses.location
let cImgUrl = allClasses.uploadURL
//make the thumb image round
tCell.classThumb.layer.borderWidth = 1
tCell.classThumb.layer.masksToBounds = false
tCell.classThumb.layer.borderColor = UIColor.lightGray.cgColor
tCell.classThumb.layer.cornerRadius = tCell.classThumb.frame.height/2
tCell.classThumb.clipsToBounds = true
Alamofire.request(cImgUrl).responseData(completionHandler: { response in
if let image1 = response.result.value {
self.thumbImage = UIImage(data: image1)!
tCell.classThumb.image = self.thumbImage
print("IMG", self.thumbImage! )
}
})
return tCell;
}
特定の日付範囲(startDateとEndDate)の間でクリックした日数に従ってテーブルビューをロードしたいだけです。以下のテーブルビューで。
私はFSCalanderを実装したことがないので、私の応答に従って明確な例(完全なコードが評価されます)を提供することによって私を助けてください。
前もって感謝します。
ステップ1)
@IBOutlet var calender: FSCalendar!
ステップ2)
calender.select(Date())
calender.scope = .week
calender.accessibilityIdentifier = "calender"
ステップ3)
callApiWillGiveresultbasedonselectedDate(currentselectedDate:String)
すべてのAPI呼び出しでのテーブルビューリロードのAPI表示の配列応答に基づく
ステップ4)
//MARK: - Calender Method
func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
self.calendarHeightConstraint.constant = bounds.height
self.view.layoutIfNeeded()
}
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
let selectedDates = calendar.selectedDates.map({self.dateFormatter.string(from: $0)})
print("selected dates is \(selectedDates)")
currentselected = "\(self.dateFormatter.string(from: date))"
callApiWillGiveresultbasedonselectedDate(currentselectedDate: currentselected)
if monthPosition == .next || monthPosition == .previous {
calendar.setCurrentPage(date, animated: true)
}
}
func calendarCurrentPageDidChange(_ calendar: FSCalendar) {
print("\(self.dateFormatter.string(from: calendar.currentPage))")
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加