简体   繁体   中英

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

So I am new to programming in swift and I am stuck. I am trying to add an calender to the left hand side by using splitview so that for each date I can save a sketch to it. How would I use the splitview function to write code for a calender? Or do I need to do it another way? Please view the picture below to get a better idea of it. All I need help with is if there is a way to manipulate splitview into using it more than just a table or is it another way to complete this project? 在此处输入图片说明

Yeah, so there's totally a way to do that. I'm just assuming you want to show a calendar for the current month.

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

Simply use a UITableViewDataSource to finish this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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