1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #import "XLFormCheckCell.h"
- @implementation XLFormCheckCell
- #pragma mark - XLFormDescriptorCell
- - (void)configure
- {
- [super configure];
- self.accessoryType = UITableViewCellAccessoryCheckmark;
- self.editingAccessoryType = self.accessoryType;
- }
- - (void)update
- {
- [super update];
- self.textLabel.text = self.rowDescriptor.title;
- self.accessoryType = [self.rowDescriptor.value boolValue] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
- self.editingAccessoryType = self.accessoryType;
- CGFloat red, green, blue, alpha;
- [self.tintColor getRed:&red green:&green blue:&blue alpha:&alpha];
- self.selectionStyle = UITableViewCellSelectionStyleDefault;
- if (self.rowDescriptor.isDisabled){
- [self setTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:0.3]];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- else{
- [self setTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:1]];
- }
- }
- -(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller
- {
- self.rowDescriptor.value = [NSNumber numberWithBool:![self.rowDescriptor.value boolValue]];
- [self.formViewController updateFormRow:self.rowDescriptor];
- [controller.tableView deselectRowAtIndexPath:[controller.form indexPathOfFormRow:self.rowDescriptor] animated:YES];
- }
- @end
|