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
Post a Comment