繁体   English   中英

我如何操作主表,以便在 Swift 中使用 splitview 时可以向其添加日历

[英]How can i manipulate an master table so i can add an calender to it when using splitview in Swift

所以我是 swift 编程的新手,我被卡住了。 我正在尝试使用 splitview 在左侧添加一个日历,以便我可以为每个日期保存一个草图。 我将如何使用 splitview 函数为日历编写代码? 或者我需要以另一种方式来做吗? 请查看下面的图片以更好地了解它。 我需要帮助的只是是否有一种方法可以操纵 splitview 使其不仅仅是使用表格,还是它是完成此项目的另一种方式? 在此处输入图片说明

是的,所以完全有办法做到这一点。 我只是假设您想显示当月的日历。

let calendar = Calendar.current
// If you wanted, you could easily change the 0 below to any number to get months in the future.
let targetDate = calendar.date(byAdding: .month, value: 0, to: Date(), wrappingComponents: false)!
let targetMonth = calendar.component(.month, from: targetDate)
let targetYear = calendar.component(.year, from: targetDate)
var targetMonthComponents = DateComponents()
targetMonthComponents.year = targetYear
targetMonthComponents.month = targetMonth
let targetMonthDate = calendar.date(from: targetMonthComponents)!
let numberOfDays = calendar.range(of: .day, in: .month, for: targetMonthDate)!.count

只需使用 UITableViewDataSource 即可完成此操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM