ios - Enable save button using shouldChangeTextInRange -


i trying create save button becomes enabled when user enters text both textview , textfield.

i have iboutlet called 'savebutton' created button.

with following code, save button never becomes enabled.

- (void) enablesavebuttonforquote: (nsstring *) quotetext author: (nsstring *) authortext {  self.savebutton.enabled = (quotetext.length > 0 && authortext > 0); }  - (bool)textview:(uitextview *)textview shouldchangetextinrange: (nsrange)range replacementtext:(nsstring *)text {    nsstring *changedstring = [textview.testringbyreplacingcharactersinrange: range withstring: text];  [self enablesavebuttonforquote: changedstring author:  self.authortextfield.text];     return yes; }  - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange: (nsrange)range replacementstring:(nsstring *)string { nsstring *changedstring = [textfield.text stringbyreplacingcharactersinrange: range withstring: string];  [self enablesavebuttonforquote:self.quotetextview.text author:changedstring]; return yes; } 

you can use bool value make happen

- (bool)textview:(uitextview *)textview shouldchangetextinrange: (nsrange)range replacementtext:(nsstring *)text {    //lets enter text first textview  textviewboolvalue=yes;   if(textviewboolvalue && textfieldboolvalue ){           button.enabled=yes    }    return yes; }  - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange: (nsrange)range replacementstring:(nsstring *)string {   textfieldboolvalue=yes;   if(textviewboolvalue && textfieldboolvalue ){           button.enabled=yes    } return yes; } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -