xmartlabs / XLForm

XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. Fully compatible with Swift & Obj-C.
MIT License
5.77k stars 953 forks source link

Why can't I assign a label to textField.rightView of two rows? #970

Open eveloson opened 7 years ago

eveloson commented 7 years ago

I create a UILabel and assign it to two rows by "[row.cellConfig setObject:paddingLabel forKey:@"textField.rightView"]". But It made app suspended and cost more and more memory,I just want to reduce memory. How can I fix this problem? qq20170623-111751


#import "DaikuanCounterViewController.h"

@interface DaikuanCounterViewController ()

@end

@implementation DaikuanCounterViewController

- (instancetype)init{
    XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"贷款额度计算器"];
    XLFormSectionDescriptor * section;
    XLFormRowDescriptor * row;
    form.assignFirstResponderOnShow = YES;
    //        For right padding :
    UILabel *paddingLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, -2, 20, 20)];
    paddingLabel.text = @"元";
    //公积金账户余额
    section = [XLFormSectionDescriptor formSection];
    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"tel" rowType:XLFormRowDescriptorTypeAccount title:@"公积金账户余额:"];
    [row.cellConfigAtConfigure setObject:@"请输入公积金账户余额" forKey:@"textField.placeholder"];
    [row.cellConfigAtConfigure setValue:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
    [row.cellConfig setObject:paddingLabel forKey:@"textField.rightView"];
    [row.cellConfig setObject:@(UITextFieldViewModeAlways) forKey:@"textField.rightViewMode"];
    row.required = YES;
    [section addFormRow:row];
    [form addFormSection:section];

    //配偶公积金账户余额
    section = [XLFormSectionDescriptor formSection];
    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"tel" rowType:XLFormRowDescriptorTypeAccount title:@"配偶公积金账户余额"];
    [row.cellConfigAtConfigure setObject:@"请输入配偶公积金账户余额" forKey:@"textField.placeholder"];
    [row.cellConfigAtConfigure setValue:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
    [row.cellConfig setObject:paddingLabel forKey:@"textField.rightView"];
    [row.cellConfig setObject:@(UITextFieldViewModeAlways) forKey:@"textField.rightViewMode"];
    row.required = YES;
    [section addFormRow:row];
    [form addFormSection:section];

    //*****************************
    return [super initWithForm:form];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}