使用 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]
}
}