A2345sooted A2345sooted - 3 months ago 13
Swift Question

Row Edit Actions not working Couchbase Lite iOS 1.3

Ever since upgrading to couchbase lite v 1.3 for ios from 1.2.1, the tableview methods related to row edit actions are not being called.

Here is how I have a view controller set up:

class MyClass: UIViewController, CBLUITableDelegate {

...
@IBOutlet weak var tableView: UITableView!
var database: CBLDatabase!;
let datasource: CBLUITableSource = CBLUITableSource();

...

override func viewDidLoad() {
super.viewDidLoad()
self.database = DataService.sharedInstance.getDatabase();
self.datasource.query = self.database.viewNamed("userNotifsView").createQuery().asLiveQuery();
self.datasource.tableView = self.tableView;
self.tableView.dataSource = self.datasource;
self.tableView.delegate = self;
}

!!! CALLED !!!
func couchTableSource(source: CBLUITableSource, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell? {
let cell = tableView.dequeueReusableCellWithIdentifier("TestCell", forIndexPath: indexPath) as! MostViewedTableViewCell;
let row = self.datasource.rowAtIndex(UInt(indexPath.row));
let notif = row!.value as! NSDictionary;
cell.mLabel?.text = notif["message"] as? String;
return cell;
}

!!! CALLED !!!
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true);
}

!!! NEVER CALLED !!!
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
print("#############################");
print("edit actions for row at index path");
print("#############################\n\n\n\n");

let myAction = UITableViewRowAction(style: .Normal, title: ...
...

myAction.backgroundColor = UIColor.orangeColor()
return [myAction];
}

!!! NEVER CALLED !!!
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
print("#############################");
print("can edit row at index path");
print("#############################\n\n\n\n");
return true
}

!!! NEVER CALLED !!!
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
print("#############################");
print("commit editing style");
print("#############################\n\n\n\n");
}


The cellForRowAtIndexPath on the couch table source is being called as I can customize the cells. The didSelectRowAtIndexPath is being called, which is strange because it is a tableView method. The 3 editing action related methods aren't being called. This was working fine about a week ago. I then moved onto other things, upgraded to v1.3 for CBL iOS and came back around to this and blugh... doesn't work. Tried downgrading back down to 1.2.1, no good. The most on point post I found about this a guy had to delete all the connections on his storyboard, which I did and rehook everything back up. I've created new projects... not working anywhere.

Any ideas? Maybe I'm missing something stupid? Bug in 1.3?

Answer
replication.deletionAllowed = true;

solves the problem.

Comments