Several properties of ScrollView Contentsize Contentoffset Contentinset

Source: Internet
Author: User

Contentsize is an area where scrollview can be scrolled, such as frame = (0, 0, 320, 480) Contentsize = (960), which means that your scrollview can scroll up and down, and the scrolling area is twice times the size of the frame.

Contentoffset is the offset of the ScrollView current display area vertex relative to the frame vertex, such as the last example you pulled to the bottom, Contentoffset is (0, 480), that is, y offset 480

Contentinset is the vertex of the ScrollView Contentview relative to the ScrollView position, for example your contentinset = (0, 100), then your contentview is from ScrollView ( 0, 100) Start showing

In addition UITableView is the subclass of Uiscrollview, they are different in the above attribute, Tabelview Contentsize is implemented by the following methods.

-(Nsinteger) numberofsections;

-(Nsinteger) Numberofrowsinsection: (nsinteger) Section;

-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath;

-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) Section;

-(CGFloat) TableView: (UITableView *) TableView heightforfooterinsection: (nsinteger) Section;

It will automatically calculate all the heights and to make the height of the contentsize for it.

For example you're in the delegate method

-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {

return 100;

}

So the contentsize of your Tabelview is (320, 4400)

Several properties of ScrollView Contentsize Contentoffset Contentinset

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.