Ios development Note TextView

Source: Internet
Author: User

Ios development Note TextView

1. cannot scroll

self.scrollEnabled = NO;

2. Normal font

[UIFont systemFontOfSize:30.0f]

3. bold font

[UIFont boldSystemFontOfSize:30.0f]

4. Text Box offset

self.textContainerInset = UIEdgeInsetsMake(TEXTVIEW_TOP_INSET, TEXTVIEW_LEFT_INSET, TEXTVIEW_BOTTOM_INSET,TEXTVIEW_RIGHT_INSET);

5. Get the input status

[self becomeFirstResponder];

6. editable or not

[self setEditable:YES];

7. Restrict the input length

According to this idea, the length of the text to be generated = the length of the original text-the length of the selected text + the length of the input text. Considering the deletion, my code is as follows:-(BOOL) textView :( UITextView *) textView shouldChangeTextInRange :( nsange) range replacementText :( NSString *) text {if ([text is1_tostring: @ ""] & range. length> 0) {// The delete character must be safe return YES;} else {if (textView. text. length-range. length + text. length> MAX_INPUT_LENGTH) {UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "beyond the maximum allowed length" message: nil delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil]; [alert show]; return NO;} else {return YES ;}}}

8. You cannot select

[self setSelectable:YES];


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.