"Go" iOS control Uiscrollview location---------gradually accumulate

Source: Internet
Author: User

Original URL: http://blog.csdn.net/z343929897/article/details/8106408

The properties of the Uiscrollview's judgment position are as follows:  
    • Contentsize:cgsize type, ScrollView can slide the area, for example, a view of the frame for (0,0,320,480), and ScrollView contentsize for (320,1080), Indicates that the vertical slide area of the ScrollView is 3 times times that of the entire screen.
    • The content display area of the Contentview:scrollview, in general, and the ScrollView contentsize are consistent.
    • The Contentoffset:cgpoint type that represents the offset of the current display area vertex relative to the frame vertex, as in the example above, if the value of contentoffset at a certain point is (0,960), The ScrollView is represented as an offset of (0,960).
    • The contentinset:uiedgeinsets type, the vertex of the Srollciew contentview relative to the location of the ScrollView, which identifies where the Contenview starts to appear, This property is similar to the margin property in CSS and XAML.

Once you know the above concepts, it is much easier to determine whether Srollciew is sliding to the bottom, as shown in the code below:

Cgpoint offset = Scrollview.contentoffset;

CGRect bounds = scrollview.bounds;

Cgsize size = scrollview.contentsize;

Uiedgeinsets inset = Scrollview.contentinset;

CGFloat currentoffset = Offset.y + bounds.size.height–inset.bottom;

CGFloat maximumoffset = size.height;

When the values of Currentoffset and maximumoffset are equal, that means ScrollView has slipped to the bottom.

In the same vein, the difference between the two offsets can also be achieved when sliding to an area, doing something else, such as when sliding to 50 pixels from the bottom, loading more data in the background:

if ((Maximumoffset–currentoffset) <50.0)

NSLog (@ "Loadmore ...");

"Go" iOS control Uiscrollview location---------gradually accumulate

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.