我正在尝试将数据传递UITableview给另一个UITableview,当我按下时我成功传递数据cell但是当我按下导航栏的后退按钮时我无法传回数据; 我已经尝试过全局变量来解决这个问题,但由于我将这些变量的日期存储在数据库中,这给我带来了很多问题,因为它强制执行所有存储的提醒以保存相同的数据,我可以做一些技巧解决这个问题,但我们都知道全局变量是不好的做法而且OOP都不确认MVC,问题是如何使用Prepare for segue函数传回数据; 请注意,表视图是静态的而不是动态的.
如果你问的是我试图传递的数据是星期几,例如选择星期五和星期六时它会将真值发送回前一个视图,如果取消选择星期五和星期六,则会将错误值发送回上一个视图
那我怎么解决这个问题呢?
提前致谢
当我加载带有选中单元格的表格视图并且我想取消选中特定单元格时,我需要在单元格上点击两次以取消选中它,我想我知道问题出在哪里,但我不知道如何解决这个问题?
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("daySelected", forIndexPath: indexPath)
cell.selectionStyle = .None
cell.textLabel?.text = days[indexPath.row]
if indexPath.row == 0 && day[0] == true{
cell.accessoryType = .Checkmark
}
return cell
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if let cell = tableView.cellForRowAtIndexPath(indexPath) {
cell.accessoryType = .Checkmark
}else{
cell!.accessoryType = .None
}
if indexPath.row == 0{
day[0] = true
}
}
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
if let …Run Code Online (Sandbox Code Playgroud)