Cannot get editActionsForRowAtIndexPath: to work
Closed this issue · 10 comments
Hi! No matter what I do I cannot get this to work.
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let block = UITableViewRowAction(style: .Normal, title: "Block") { action, index in
print("Block")
}
let delete = UITableViewRowAction(style: .Default, title: "Delete") { action, index in
print("Delete")
}
return [delete, block]
}
func dataSource(dataSource: DATASource, tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
func dataSource(dataSource: DATASource, tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
}
IMHO you are missing something like this
func dataSource(dataSource: DATASource, tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]?
In case not, please correct me.
Thank you!
Hi Tomas,
Thanks for reporting this issue! I'll have a look at it. 😄
@syky27 Hi!
That's a UITableViewDelegate method, DATASource only takes care of the UITableViewDataSource methods.
Best
@syky27 There you go. I added an example on how to do what you asked.
https://github.com/3lvis/DATASource/blob/master/DATASourceDelegateTableSwift/ViewController.swift
You need to implement this method in the DATASourceDelegate
func dataSource(dataSource: DATASource, tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
Hi! So I tried to download your example, but after running it on my iPhone it crashes on
dyld`dyld_fatal_error:
-> 0x12002d088 <+0>: brk #0x3
Is it happening to you also?
@syky27 wow, this is really weird. Might be something related to your Xcode installation.
@3lvis Then I suppose it works for you right? I was trying to run your example because I still cannot get the swiping to work...
I will try to compile my app on my Mac Build Server, Then I will let you know...
Thanks
Hi! So I reinstalled Xcode, and it started to work... One just simply needs to hate how dev. tools from Apple are unstable nowadays....
Thanks for help tho.