iosobjective-cxcodexlform

XLForms together with units


What is the best way to use XLForms together with units like kg, weeks, money (euros, dollar) etc.

Basically I'd like my rows to show the entered value followed by the correct unit.


Solution

  • Your question is far too vague. This is something you have to figure out as there is no 'best way'. You can subclass the custom cells XLForms use and override the configure and update methods and adjust the values displayed accordingly. Subclassing and customizing XLFormBaseCell will get you the most flexible results. Example:

     - (void)configure
    {
        [super configure];
        self.textField.text = self.rowDescriptor.value && ![self.rowDescriptor.value isKindOfClass:[NSNull class]] ? @"" : self.rowDescriptor.value;
    }
    
    - (void)update
    {
        [super update];
    
        self.textField.textColor = self.rowDescriptor.disabled ? [UIColor colorWithRed:32.0/255.0 green:27.0/255.0 blue:27.0/255.0 alpha:1.0] : [UIColor blackColor];
        self.textField.font = [UIFont fontWithName:@"Montserrat-Regular" size:18];
    }