Use of ScrollView, and scrollview

Source: Internet
Author: User

Use of ScrollView, and scrollview

1. UIScrollView has two sub-classes: uitextview and uitableview. These two controls are frequently used. Therefore, it is necessary to master their usage. They provide horizontal or vertical scroll bars when the content exceeds the screen.

 

2. Three main attributes: contentSize, contentInset, and contentOffset.

2.1 first,Be sure to set contentSize(The size occupied by the actual content in the control) This attribute must be set to a greater range than that displayed on the control screen to display the scroll effect.

For example, if the size of a scrollview is (), you can set the size as follows to display the content in the range () through the scroll bar.

- (void)viewDidLoad{    [super viewDidLoad];   // Do any additional setup after loading the view, typically from a nib.    self.scrollView.contentSize = CGSizeMake(900, 1200);}

 

2.2 contentInset this attribute is a blank size of the border, relatively simple.

2.3ContentOffsetNote that this attribute is used to set the display range of the Start Control.

For example, if you want to make the initial display of content with an offset of 200 in the y direction, the following settings will show the dynamic effect of moving 200 downward.

-(void)viewDidAppear:(BOOL)animated
{ [self.scrollView setContentOffset:CGPointMake(0, 200) animated:YES];}

 

3. Remember to cancel the check option in the story board.Use auto layoutOtherwise, scrollview scrolling fails.

All of the above are simple to use and will be supplemented in the future.

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.