Skip to content

Commit

Permalink
cell.userInteractionEnabled is now equal to the enabled property of t…
Browse files Browse the repository at this point in the history
…he 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)
  • Loading branch information
bartvandendriessche committed Apr 12, 2013
1 parent 9d2a21e commit 2323d23
Showing 3 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion quickdialog/QButtonElement.m
Original file line number Diff line number Diff line change
@@ -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;
}

1 change: 0 additions & 1 deletion quickdialog/QElement.m
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions quickdialog/QuickDialogDataSource.m
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 2323d23

Please sign in to comment.