Basic view of iOS development--uitextview

Source: Internet
Author: User

The multiline Text control (Uitextview) inherits the Uiscrollview:uiview control, so it defaults to scroll bars.

The difference between Uitextfield and Uitextview

Uitextfield

Can enter a single line of data

Uitextview

Ability to enter multiple rows of data

Uitextview does not inherit parent class, binding event operation is inconvenient

Uitextview inherits Uiscrollview, supports vertical and horizontal scroll bars



viewcontroller.m//uitextviewdemo////Created by Apple on 16/5/11.//copyright©2016 year. All rights reserved.//#import "ViewController.h" @interface Viewcontroller () @end @implementation viewcontroller//    Declares a global uitextview text field uitextview* textview;-(void) viewdidload {[Super viewdidload];        Initialize the Uitextview text field of the above declaration textView = [[Uitextview alloc] Initwithframe:cgrectmake (50,300,200,100)];    Set its background color textview.backgroundcolor = [Uicolor Graycolor];    Set the font color inside the textView textview.textcolor = [Uicolor blackcolor];    Set what is displayed by default Textview.text = @ "Please enter more information";    Sets whether to enable scrolling textview.scrollenabled = YES;    Turn on whether to show boundary textview.showshorizontalscrollindicator = YES;    Sets the out-of-bounds time if there is a spring effect (default YES) textview.bounces = yes;    Keyboard type textview.keyboardtype = Uikeyboardtypedefault;    The type of the return key textview.returnkeytype = Uireturnkeydefault;   Add to Current View [Self.view Addsubview:textview];} When touching an empty space in a non-text field, turn off the keyboard-(void) Touchesbegan: (Nsset *) touches withEvent: (uievent *) uievent{[TextView Resignfirstresponder];} @end

As follows:


Basic view of iOS development--uitextview

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.