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