ios - How to disable/enable all textfields in a viewcontroller -


this more question best practices. have view many text fields, , need method toggle between enabling , disabling text fields simultaneously. 1 way think work, following:

- (void)activatetextfields:(bool)activate {     [firsttextfield setuserinteractionenabled:activate];     [secondtextfield setuserinteractionenabled:activate];     ...     [lasttextfield setuserinteractionenabled:activate]; } 

however, i'm wondering if there better way (given vast number of fields) single line disable/enable text fields @ once.

thanks help!

you place transparent view on top of text fields userinteraction enabled, "trap" taps , stop them going text fields.

edit: better: return no method:

textfieldshouldbeginediting: asks delegate if editing should begin in specified text field.

- (bool)textfieldshouldbeginediting:(uitextfield *)textfield parameters textfield text field editing begin. return value yes if editing session should initiated; otherwise, no disallow editing.

that way, there's 1 bit of state change, class's "shouldtextfieldsallowediting" boolean property.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -