SkyFloatingLabelTextField icon indicating copy to clipboard operation
SkyFloatingLabelTextField copied to clipboard

Text's end is hidden when it get the field's width limit

Open felipesantanadev opened this issue 6 years ago • 3 comments

When I'm typing the text on the field and it get at the end of the field, the string keeps increasing, but visually the text is hidden.

If I press the left arrow on the keyboard (<-) to back positions on the text, the hidden piece of string is shown.

I have already tested in a real device and I'm getting the same error.

I expect that the text become visible while we are typing, even if the field's width be overflown.

This image represents the moment that I was typing without stopping. captura de tela 2018-11-22 as 20 17 45

And this image represents when I stop typing and press the left arrow key (<-).

captura de tela 2018-11-22 as 20 18 22

Environment

Xcode Version: 9.4 SkyFloatingLabelTextField Version: 3.6 Deployment Target: iPhone 6 and iPhone 8 Method of Integration: CocoaPods

felipesantanadev avatar Nov 22 '18 22:11 felipesantanadev

I think that is not the better solution, but I solved the problem by creating the following function:

func putCaretAtTheEnd()
    {
        if(selectedTextRange?.end == endOfDocument)
        {
            let arbitraryValue: Int = text!.count - 1
            if let newPosition = position(from: beginningOfDocument, offset: arbitraryValue) {
                selectedTextRange = textRange(from: newPosition, to: newPosition)
                textAlignment = .left
            }
            
            let arbitraryValue2: Int = text!.count
            if let newPosition2 = position(from: beginningOfDocument, offset: arbitraryValue2) {
                selectedTextRange = textRange(from: newPosition2, to: newPosition2)
                textAlignment = .left
            }
        }
    }

It's called inside the editingChanged() in SkyFloatingTextField.swift:

@objc open func editingChanged() {
        updateControl(true)
        updateTitleLabel(true)
        putCaretAtTheEnd()
    }

felipesantanadev avatar Nov 23 '18 17:11 felipesantanadev

Hi, The function is working fine. But still a char is visible partially.

antonyjamese avatar Feb 01 '19 09:02 antonyjamese

This happens if height of SkyFloatingLabelTextField is too small. Setting 50.0 as height resolves this issue.

Davtyanag avatar Mar 20 '19 14:03 Davtyanag