Material: Programatically Set Text on TextField

Created on 25 Apr 2016  路  14Comments  路  Source: CosmicMind/Material

Setting textField.text programatically has some weird side effects on the titleLabel after interaction.

bug help wanted question

Most helpful comment

@mohpor @saipnc @zgosalvez Hi, I rewrote the TextField, under the temporary class MTextField and added an example of its usage in the Programmatic/TextField example project. My aim is to simplify the interface and have a cleaner code base going forward. @zgosalvez I have spent quite a bit of time making sure that it follows the spec as best as iOS can. There is a little more work to do, not much and then I can release it. I was hoping you guys would be able to take a look. I have also been working on a documentation site, which I will push later today.

Things to note:

  • I have removed the default clearButton - found that conflicted with the iOS clearButton.
  • I have simplified the API and want to keep it as minimal as possible.
  • I have rethought the entire approach of dealing with TextFields and input animations.
  • I need to add placeholder highlighting, formally known as title -> this should be an easy step.

Thanks guys, I will be finalizing this today, and then moving to AlertView, pulse animation, and SideNav.

This is all in the development branch.

All 14 comments

Can elaborate on what is the weird side effects?

The title label does not appear

Are you setting a placeholder? I will try now.

Yes, a placeholder is also set.

This is a confirmed bug. I will fix it today.

@danieldahan yes we are also facing the same issue if we set text programmatically the title label disappears with a weird animation. If you could fix this it would be great.

Hey, @danieldahan

After going through your code, I figured out that by setting the test field data programmatically the delegate methods are not getting invoked. Because of which the title label is not getting set.

Ex: When we type in text field the delegates are called and the title label is set, but when we set text like textField.text = "Something" then delegates are not called and title label is not set

I tried doing the following "hack," but didn't work, probably because of race conditions with the animations.

textField.sendActionsForControlEvents(.EditingDidBegin)
textField.text = "something"
textField.sendActionsForControlEvents(.ValueChanged)
textField.sendActionsForControlEvents(.EditingDidEnd)

Yeah that would cause an issue. I am working on documentation for this release today with a fix.

Hi @danieldahan,

We need this bug fixed very badly, how long does this take?

@mohpor @saipnc @zgosalvez Hi, I rewrote the TextField, under the temporary class MTextField and added an example of its usage in the Programmatic/TextField example project. My aim is to simplify the interface and have a cleaner code base going forward. @zgosalvez I have spent quite a bit of time making sure that it follows the spec as best as iOS can. There is a little more work to do, not much and then I can release it. I was hoping you guys would be able to take a look. I have also been working on a documentation site, which I will push later today.

Things to note:

  • I have removed the default clearButton - found that conflicted with the iOS clearButton.
  • I have simplified the API and want to keep it as minimal as possible.
  • I have rethought the entire approach of dealing with TextFields and input animations.
  • I need to add placeholder highlighting, formally known as title -> this should be an easy step.

Thanks guys, I will be finalizing this today, and then moving to AlertView, pulse animation, and SideNav.

This is all in the development branch.

@saipnc @zgosalvez please take part in this issue.

@saipnc You can now do this in the new TextField, temporary name MTextField, which is now in development. Please track any changes prior to release here 342. I am closing this issue to consolidate all TextField issues in 342.

@danieldahan Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

0zguner picture 0zguner  路  16Comments

kylebrowning picture kylebrowning  路  15Comments

VNadygin picture VNadygin  路  18Comments

karstengresch picture karstengresch  路  15Comments

tato469 picture tato469  路  17Comments