如何快速开始和结束一周?这是我的代码
extension Date {
var startOfWeek: Date? {
let gregorian = Calendar(identifier: .gregorian)
guard let sunday = gregorian.date(from: gregorian.dateComponents([.yearForWeekOfYear, .weekOfYear], from: self)) else { return nil }
return gregorian.date(byAdding: .day, value: 1, to: sunday)
}
var endOfWeek: Date? {
let gregorian = Calendar(identifier: .gregorian)
guard let sunday = gregorian.date(from: gregorian.dateComponents([.yearForWeekOfYear, .weekOfYear], from: self)) else { return nil }
return gregorian.date(byAdding: .day, value: 7, to: sunday)
}
}
Run Code Online (Sandbox Code Playgroud)
我这样打电话
let startWeek = Date().startOfWeek
let endWeek = Date().endOfWeek
print(startWeek!)
print(endWeek!)
var dateFormat1 …Run Code Online (Sandbox Code Playgroud) 如何使用自定义按钮选择tableview行。我有另一个按钮,称为“在表视图之外选择其所有内容”。我的问题是,在单击表视图按钮之外时,如何选择和取消选择表视图内部的行?同时我可以在tableview中选择单行吗?如何快速完成3?这是我在cellforrow方法中的代码
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let identifier = "Custom"
var cell: TStudentAttendanceCell! = tableView.dequeueReusableCell(withIdentifier: identifier) as? TStudentAttendanceCell
if cell == nil {
tableView.register(UINib(nibName: "TStudentAttendanceCell", bundle: nil), forCellReuseIdentifier: identifier)
cell = tableView.dequeueReusableCell(withIdentifier: identifier) as? TStudentAttendanceCell
}
print("studentAttendanvceArray--",studentAttendanceArray.object(at: indexPath.row) )
var localDic :NSDictionary!
localDic = studentAttendanceArray.object(at: indexPath.row) as! NSDictionary
Common.sharedInstance.StopActivity()
cell.profile_img.image = self.image
cell.name_lbl.text = localDic["student_name"] as? String
cell.selectionStyle = UITableViewCellSelectionStyle.none
cell.contentView.backgroundColor = UIColor.clear
let whiteRoundedView : UIView = UIView(frame: CGRect(x: 10, y: 8, width: self.view.frame.size.width …Run Code Online (Sandbox Code Playgroud) 如何像Android中一样动态设置Tableview高度。我尝试使用以下代码,但无法正常工作。
tblHeightConstraint.constant = downSelectionTbl.contentSize.height
Run Code Online (Sandbox Code Playgroud)
看到下面的链接,即使它不能解决我的问题,我也很讨厌投票。