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