The use of the screen scrolling control ScrollView

Source: Internet
Author: User

1.UIScrollView has 2 subclasses, Uitextview and UITableView, and these two controls are often needed, so it is necessary to master its use. They are both horizontal or vertical scrollbars that can be provided when the content is out of the screen.

2. The main 3 properties, Contentsize, Contentinset, and Contentoffset.

2.1 First, be sure to set the Contentsize(the size of the actual content in the control) this property, and this property to be set more than the screen display of the control of the range, to appear scrolling effect.

For example, if the size of the ScrollView is (768,1000), the contents of the (900,1200) range can be displayed in (768,1000) through the scrollbar, as set out below.

-(void) viewdidload{    [Super Viewdidload]; Additional setup after loading the view, typically from a nib.    Self.scrollView.contentSize = Cgsizemake (900, 1200);}

2.2 Contentinset This property is the border blank size, relatively simple.

2.3 Contentoffset This property to note, its role is to set the starting control to display the range.

For example, if you want the initial display to offset the contents of y-direction 200, the following setting will have a dynamic effect of moving down by 200.

-(void) Viewdidappear: (BOOL) animated
{ [Self.scrollview setcontentoffset:cgpointmake (0, $) animated:yes];}

3. Remember to cancel the check option in the storyboard use Auto layout, otherwise scrollview scrolling will fail.

All of these are simple to use and later encounter more specific use to supplement.

The use of the screen scrolling control ScrollView

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.