Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- // #warning Incomplete implementation, return the number of rows
- return chapters.count
- }
- override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "reuse", for: indexPath)
- return chapters[indexPath.row].asTableCell(cell)
- }
- override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
- // Return false if you do not want the specified item to be editable.
- return true
- }
- /*
- override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
- if editingStyle == .delete {
- _ = chapters.remove(at: indexPath.row)
- tableView.deleteRows(at: [indexPath], with: .fade)
- } else if editingStyle == .insert {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }*/
- override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
- }
- override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
- let delete = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexPath) in
- // delete item at indexPath
- self.chapters.remove(at: indexPath.row)
- tableView.deleteRows(at: [indexPath], with: .fade)
- }
- let share = UITableViewRowAction(style: .normal, title: "Share") { (action, indexPath) in
- // share item at indexPath
- print("I want to share: \(self.chapters[indexPath.row].title)")
- }
- share.backgroundColor = UIColor.lightGray
- share.backgroundEffect = UIVisualEffect()
- return [delete, share]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement