iOS Development--textview Feedback page (placeholder label, word count, interactive settings for submit button)

Source: Internet
Author: User

Record the function of a page:

TextView placeholder, Word count, submit button interactive settings, as follows:

Input effect:

The specific implementation code is as follows:

1, setting up the proxy

@interface Fkviewcontroller () <UITextViewDelegate>

2, I am the direct xib drag control

@property (Weak, nonatomic) iboutlet Uitextview ***stringlenghtlab;

3,viewdidload inside

Self. Fktextview. delegate = self ;     = NO;     = NO;     = [Uicolor Lightgraycolor];

4, the specific agent method to achieve

-(void) Textviewdidchange: (Uitextview *) textview{Self.descLab.hidden=YES; Self.sendBtn.userInteractionEnabled=YES; Self.sendBtn.backgroundColor=Maincolor; //real-time display of wordsSelf.stringlenghtLab.text = [NSString stringWithFormat:@"%ld/100",(Long) TextView.text.length]; //Word Limit    if(TextView.text.length >= -) {Textview.text= [Textview.text Substringtoindex: -]; }        //Cancel the button click Permission and display the text    if(TextView.text.length = =0) {Self.descLab.hidden=NO; Self.sendBtn.userInteractionEnabled=NO; Self.sendBtn.backgroundColor=[Uicolor Lightgraycolor]; }}-(BOOL) TextView: (Uitextview *) TextView Shouldchangetextinrange: (nsrange) Range Replacementtext: (NSString *) text{if([Text isequaltostring:@"\ n"]) {[Self.                Fktextview Resignfirstresponder]; returnNO; }        returnYES;}

Just make a record!

iOS Development--textview Feedback page (placeholder label, word count, interactive settings for submit button)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.