使用UITableViewRowAction,每行可以有不同数量的按钮吗?例如,我想要一行有3个动作,其余的用2个。有可能吗?
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
if indexPath.row == 0 {
let note = UITableViewRowAction(style: .Default, title: " Note ") { action, index in
self.notePopUpCalled()
}
note.backgroundColor = GlobalColourConstants.informationColour
let infomation = UITableViewRowAction(style: .Default, title: " Info ") { action, index in
self.informationPopUpCalled()
}
infomation.backgroundColor = GlobalColourConstants.appColour
let Diagram = UITableViewRowAction(style: .Default, title: " Diagram ") { action, index in
self.diagramPopUpCalled()
}
note.backgroundColor = GlobalColourConstants.informationColour
return [note, information, diagram]
} else {
let note = UITableViewRowAction(style: .Default, title: " Note ") { action, index in
}
note.backgroundColor = GlobalColourConstants.informationColour
let infomation = UITableViewRowAction(style: .Default, title: " Info ") { action, index in
}
infomation.backgroundColor = GlobalColourConstants.appColour
return [note, information, nil]
}
}
答案 0 :(得分:0)
是的,这是可能的。方法:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]?
返回每个索引路径的操作数组。因此,您可以为每一行返回不同的操作集。