inloop / Styles

Styling iOS apps made easy
MIT License
18 stars 2 forks source link

UITextField freezes on deleting last character #72

Closed VilemKurz closed 6 years ago

VilemKurz commented 6 years ago

Steps to reproduce

  1. Set textField.textStyle like this:
    let majorMessage = TextStyle(.foregroundColor(.white))
    let font13 = TextStyle(.font(.default13))
    let active = majorMessage + font13
    [TextInputState.editing, .inactive].forEach {
    textField.setTextStyle(active, for: $0)
    }
  2. set a text
  3. toggle text field active/inactive few times
  4. move cursor to the last position (aligned to right, so it is the rightmost position)
  5. start deleting characters.

bug behaviour: when you delete last character it is not deleted, app becomes unresponsive and app's memory comsumption grows very quickly.

expected behaviour: last character is deleted with no problems, app stays responsive.

jakubpetrik commented 6 years ago

So this turned out as UIKit issue. I have tested it with a blank project where I created following UIViewController:

class ViewController: UIViewController {
    @IBOutlet var textField: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        textField.attributedText = NSAttributedString(
            string: "apple",
            attributes: [
                .font: UIFont.systemFont(ofSize: 13),
                .foregroundColor: UIColor.red
            ]
        )
    }

    @IBAction func cancelEditing() {
        textField.resignFirstResponder()
    }
}

anyway I will try to come up with the workaround for Styles.