ios - How to delete the contents of a UITextField programmatically? -
i writing iphone app has number of uitextfields requires user input bunch of data. have simple 'delete' facility allows user discard data have put in multiple fields.
i've been struggling issue few days now. can't seem find way of reaching individual text fields , changing text. app throws errors @ me no matter try.
there several ways of tackling this.
you can write code wipe each of them individually. this, create iboutlet
each one, , assign blank string text
properties. if have couple of fields, that's simplest. if have more, it's not good.
you can make them children of common container view , loop on subviews. way, need hook single iboutlet
.
you can recurse on entire view hierarchy , blank out text fields find.
another approach, isn't documented apple, use iboutletcollection
. way, can assign of text fields 1 iboutletcollection
, loop on it. simplest, straightforward way of doing it.
Comments
Post a Comment