Uiscrollview and Uipagecontrol Control grooming

Source: Internet
Author: User

Uiscrollview can be scrolled view,uiview itself cannot scroll, subclass Uiscrollview extends the functionality of scrolling.
Uiscrollview is the base class for all scrolling views. Subsequent views such as Uitableview,uitextview are inherited from the class.
Use the scene: Not show (single large picture); Too much content (picture); scroll headlines (Pictures); albums, etc.
Uiscrollview core Functions
Uiscrollview mainly specializes in two areas:
Scrolling: Contentsize is larger than frame.size, can scroll.
Zoom: With scale, you can specify a zoom multiplier. /*
Uiscrollview do automatic layout

1. First to determine the Uiscrollview scrolling range, if not sure, just add the control will be wrong
2. Drag into a view to make this view determine the Uiscrollview scrolling range, the width of the height must be determined
2.1 Uiscrollview horizontal scrolling area view left and right side spacing + view width
2.2 Uiscrollview Vertical scrolling area view upper and lower spacing + view height

Note: If the Uiscrollview scrolling area is determined, you cannot make a view to determine
* * Properties Summary for Uiscrollview
Attribute action
Cgpoint Contentoffset Monitor the current scrolling position
Cgsize contentsize the size of the scroll range
Uiedgeinsets contentinset View in ScrollView location id<uiscrollerviewdelegate>delegate set Protocol BOOL Directionalloc kenabled Specifies whether the control can only scroll in one Direction
BOOL bounces control controls whether the border bounces
BOOL alwaysbouncevertical Controls whether a border is bouncing vertically
BOOL Alwaysbouncehorizontal Control horizontal direction encountered whether the border bounces bool pagingenabled control whether the whole page flips bool scrollenabled Controls whether the control can scroll bool Showshorizontalscrollindicator control whether the horizontal scroll bar is displayed bool Showsverticalscrollindicator control is displayed Vertical scroll bar uiedgeinsets scrollindicatorinsets Specifies the position of the scrollbar in Scrollerview Uiscrollviewindicatorstyleindicatorstyle Fixed scrollbar style float decelerationrate change the position of the deceleration point of the Scrollerview
BOOL Tracking Monitor whether the current target is being traced
BOOL dragging monitor whether the current target is being dragged
BOOL decelerating Monitor whether the current target is slowing down
BOOL Delayscontenttouches Control whether the view is delayed call to start scrolling method
BOOL cancancelcontenttouches Controls whether the control touches an event that cancels the touch
The minimum ratio of float minimumzoomscale reduction
Maximum ratio of float maximumzoomscale magnification
Float Zoomscale Set Change ratio
BOOL Bounceszoom Controls whether the zoom will rebound
BOOL zooming determines whether the size of the control is changing
BOOL zoombouncing Determines whether scaling bounces are in progress
BOOL scrollstotop control controls scroll to top

Here's a summary of some of Uiscrollview's key points:

Starting with your finger touch screen, ScrollView starts a timer if:

1. Within 150ms if your finger does not have any action, the message will be passed to Subview.

2.150ms inside the finger has obvious sliding (a swipe action), ScrollView will scroll, the message will not be passed to Subview, here is the cause of the problem two.

3.150ms the finger does not slide, scrollview the message to Subview, but then the finger starts to slide, ScrollView transmits touchescancelled message to Subview, and then starts scrolling.

Observe the situation of TableView, you first hold down a cell,cell start highlighting, hands do not let go, start sliding, tableview start scrolling, highlight Cancel. The role of Delayscontenttouches:

This flag by default is yes, using the above 150ms timer, if set to No,touch event immediately passed to Subview, there will be no 150ms waiting. The role of Cancelstouches:
This standard defaults to Yes, and if set to No, this scroll event will not happen again once the message is passed to Subview. Uiscrollview Scrolling related properties
Contentsize//define the content area size to determine if you can slide
Contentoffset//view offset from the top left corner of the coordinate origin
Scrollstotop//Sliding to the top (Point status bar)
pagingenabled//whether full screen flipping
Bounces//Border rebound
Scrollenabled//is able to scroll
Showshorizontalscrollindicator//Controls whether the horizontal scroll bar is displayed
Showverticalscrollindicator//Controls whether vertical scroll bars are displayed
Alwaysbouncevertical//Control the vertical direction to see if the frame bounces
Alwaysbouncehorizontal//Control horizontal direction encountered whether the frame bounces

Uiscrollview Scaling related properties
Minimumzoomscale//Reduced minimum ratio
Maximum ratio of maximumzoomscale//magnification
Zoomscale//Set Change ratio
zooming//Determine if scale bounce is in progress
Bounceszoom//control whether the zoom will rebound
To achieve scaling, you also need to implement delegate, which specifies who the Zoomed view is.

Second, the common agent method of Uiscrollview

Uiscrollview Rolling Agent Method Uiscrollview Scaling Agent method Iii. use of Uipagecontrol
Uipagecontrol is similar to Uilabel
Used to indicate the current page (code)
Usually used in conjunction with Uiscrollview
CurrentPage//Current page
Numberofpages//Specify the number of pages
Uipagecontrol as can be seen from the class name, its parent class is Uicontrol.
So you can add an event like a button, except that the event trigger uses not Uicontroleventstouchupinside but uicontroleventsvaluechanged.

Iv. combined use of Uipagecontrol and Uiscrollview
Modify the currentpage of Pagecontrol usually when ScrollView scrolls
Usage scenarios:
Guide page
Carousel Diagram of Home page, etc.

Summarize
Contentsize determines whether ScrollView can scroll, contentoffset control the offset of the content area, pageenabled control whether the full page scrolling.
ScrollView implementation scaling requires specifying a maximum zoom factor, a minimum scaling factor, and a zoomed view. Pagecontrol are not used alone, and are usually used in conjunction with ScrollView.

Uiscrollview and Uipagecontrol Control grooming

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.