编辑时UITextField textAlignment反向

时间:2014-10-10 13:16:27

标签: ios uitextfield text-alignment

我有一个自定义的UITextField类

- (void)awakeFromNib
{
    self.textColor = [UIColor mtcTurquoise];
    self.autocorrectionType = UITextAutocorrectionTypeNo;
    self.textAlignment = NSTextAlignmentRight;

    if (IS_IPAD) {
        self.font = [UIFont arialBoldWithSize:14];
    }
    else{
        self.font = [UIFont arialBoldWithSize:13];
    }
}

当我在UITableViewCell中添加Once时,我遇到了一些对齐问题:占位符& unedit字段很好地对齐。但是当我编辑该字段时,存在反转对齐

see bellow

static NSString * MTCInfosEditTableViewCellID = @"MTCInfosEditTableViewCell";
        MTCInfosEditTableViewCell *cell = (MTCInfosEditTableViewCell *)[tableView dequeueReusableCellWithIdentifier:MTCInfosEditTableViewCellID];
        if (cell == nil)
        {
            UIViewController *c = [[UIViewController alloc] initWithNibName:@"MTCInfosEditTableViewCell" bundle:nil];
            cell = (MTCInfosEditTableViewCell *)c.view;
        }
cell.infoTF.delegate = self;





- (void)textFieldDidEndEditing:(UITextField *)textField
{
    MTCTextFlieldTableView * tf = (MTCTextFlieldTableView *)textField;

    if ([tf.table isEqual:mainTable] && tf.indexPath.section == 0) {
        ((MTCInfos *)[self.arrayInfoUser objectAtIndex:tf.indexPath.row]).value = tf.text;
    }
    else if ([tf.table isEqual:secondTable] && tf.indexPath.section == 0) {
        ((MTCInfos *)[self.arrayPasswordUser objectAtIndex:tf.indexPath.row]).value = tf.text;
    }
}

0 个答案:

没有答案