From 2323d23fe4322b055b635532103dd85c0355435b Mon Sep 17 00:00:00 2001 From: Bart Vandendriessche Date: Fri, 12 Apr 2013 14:53:25 +0200 Subject: [PATCH] cell.userInteractionEnabled is now equal to the enabled property of the Element it belongs to. This fixes a bug that still allowed you to select cells whose Elements had been disabled dynamically. e.g.: Let's say we have 2 QPickerElements. The second QPickerElement changes it's options based on the value of the first. If the first QPickerElement value is empty, then the second QPickerElement should have no values, and should be disabled. With this fix, you can set secondQPickerElement.enabled = NO and then use UITableView's reloadRowsAtIndexPaths:withRowAnimation to properly disable it in the UITableView. This was not possible before, because the userInteractionEnabled property was only set correctly in the implementation of QButtonElement and QElement, which wasn't always reached because not all QElement subclasses call super (e.g. QPickerElement) --- quickdialog/QButtonElement.m | 1 - quickdialog/QElement.m | 1 - quickdialog/QuickDialogDataSource.m | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/quickdialog/QButtonElement.m b/quickdialog/QButtonElement.m index 6e0a2c08..c002b9ac 100644 --- a/quickdialog/QButtonElement.m +++ b/quickdialog/QButtonElement.m @@ -42,7 +42,6 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr cell.textLabel.textAlignment = self.appearance.buttonAlignment; cell.textLabel.font = self.appearance.labelFont; cell.textLabel.textColor = self.enabled ? self.appearance.actionColorEnabled : self.appearance.actionColorDisabled; - cell.userInteractionEnabled = self.enabled; return cell; } diff --git a/quickdialog/QElement.m b/quickdialog/QElement.m index 99211da0..fc2f200e 100644 --- a/quickdialog/QElement.m +++ b/quickdialog/QElement.m @@ -63,7 +63,6 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr cell.textLabel.text = nil; cell.detailTextLabel.text = nil; cell.imageView.image = nil; - cell.userInteractionEnabled = self.enabled; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.showsReorderControl = YES; cell.accessoryView = nil; diff --git a/quickdialog/QuickDialogDataSource.m b/quickdialog/QuickDialogDataSource.m index 3728fdf3..d0ae1e7d 100644 --- a/quickdialog/QuickDialogDataSource.m +++ b/quickdialog/QuickDialogDataSource.m @@ -34,6 +34,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N QSection *section = [_tableView.root getVisibleSectionForIndex:indexPath.section]; QElement *element = [section getVisibleElementForIndex:indexPath.row]; UITableViewCell *cell = [element getCellForTableView:(QuickDialogTableView *) tableView controller:_tableView.controller]; + cell.userInteractionEnabled = element.enabled; return cell; }