ios - I need to get the referencing outlet, or some other identifier from the sender (UITextView) -
warning: new ios development not coding in general.
i trying validation on uitextview, several actually. have different requirements length. have created custom delegate handle running issue figuring out how make unique textview sending it.
i have several fields in several different nibs make use of delegate. of nibs have 3 textviews labeled like: summary, detail , special instructions. each of these has different max length 50, 100, 130 respectively.
tl:dr; how can unique id each sender can switch on them?
edit: update label, hidden until needed, count down available chars left. how make sure accessing correct controller , label?
in delegate protocol, define way send uitextview instance along else, like:
@protocol uitextfieldvalidationdelegate - (bool) textfield:(uitextfield)tf textforvalidation:(nsstring *)newtext; @end
so when uitextfields call this, pass in inspection delegate:
bool valid = [self.delegate textfield:self textchanged:newtext];
in delegate, you'll implement as:
- (bool) textfield:(uitextfield)tf textforvalidation:(nsstring *)newtext { //compare iboutlets if (tf == self.tfphonenumber) { //do phone number validation } else if (tf == self.tfemail { //do email validation } if (valid) { return yes; } else { return no; } }
Comments
Post a Comment