UITextField has trailing whitespace after secureTextEntry toggle

后端 未结 18 1217
逝去的感伤
逝去的感伤 2020-12-29 19:27

I have a button that toggles between Show/Hide mode (i.e. toggles a UITextField between secureTextEntry NO and YES). The purpose of which is to allow the user to see the pa

18条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 20:22

    Here is the solution:

    - (void)showHidePassword:(UIButton *)sender {
        EDSignUpCell *cell = [self.signUpTblView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:3 inSection:0]];
        if(!TRIM_SPACE(cell.cellTextField.text).length) {return;}
        [cell.showHidePasswordBtn setSelected:!cell.showHidePasswordBtn.isSelected];
        cell.cellTextField.secureTextEntry = cell.showHidePasswordBtn.isSelected;
        [cell.cellTextField setText:cell.cellTextField.text];
        [cell.cellTextField becomeFirstResponder];
    }
    

提交回复
热议问题