Uiscrollview is a scrolling view
Our mobile phone has a limited screen size and we need to use this control when we want to display a large picture.
More content can be displayed on a limited screen
1, how to use Uiscrollview scrolling
1> drag into a Uiscrollview control
2> adding content to a control
3> setting Contentsize Description of the range that can be scrolled
Common Properties for 2.UIScrollView
1>contentsize setting the range of scrolling
2>scrollenabled set whether the picture scrolls
3>userinteractionenabled Setting up user interaction
4>contentoffset usually see offset refers to the deviation, you need to move the content to the desired place, you need to use the offset value is noted. Change the offset to see that the distance can be used to control the scrolling of the content
5>contentinset is a structural problem that represents the padding of content. Contentinset do not participate in the calculation of offset
6> bounces set Spring effect
7> showhorizontalscrollindicater Setting Horizontal scroll bar
8> showverticalscrollindicater Set Vertical scroll bar
1 // Contentoffset has an animated method 2 [self.scrollview setcontentoffset: Offset distance, if wide and higher than uiscrollview width and height, Can be replaced with a 0 band animated: whether animation]
Proxy method for 3.UIScrollView:
1- (void) Scrollviewdidscroll: (Uiscrollview *) ScrollView {2//This method is the method that is called whenever Uiscrollview is scrolled .3 }4 5- (void) Scrollviewwillbegindragging: (Uiscrollview *) ScrollView {6 //start dragging when called, emphasizing the beginning7 }8 9- (void) Scrollviewwillenddragging: (Uiscrollview *) ScrollView withvelocity: (cgpoint) Velocity targetcontentoffset: (inout Cgpoint *) Targetcontentoffset {Ten//call when your finger is lifted One } A -- (void) Scrollviewdidenddragging: (Uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate { -//call when your finger is lifted the } - -- (void) Scrollviewwillbegindecelerating: (Uiscrollview *) ScrollView { - //if the finger is lifted, the ScrollView is still moving because of inertia, this method will call + } - +- (void) Scrollviewdidenddecelerating: (Uiscrollview *) ScrollView { A//after the finger moves, it is called because the inertia stops. If there is no inertia when the finger is moved, this method does not call at } - -- (void) Scrollviewdidendscrollinganimation: (Uiscrollview *) ScrollView { -//Use setcontentoffset:animated: Method, there is animation when the animation ends when called, otherwise it will not be called - } - in The status bar must be displayed --(BOOL) Scrollviewshouldscrolltotop: (Uiscrollview *) ScrollView { to//Click on the status bar, ScrollView will automatically scroll to the beginning of the position, if return no will not respond + Yes by default -returnNO; the } * $- (void) Scrollviewdidscrolltotop: (Uiscrollview *) ScrollView {Panax Notoginseng//called after scrolling to the top - } the +- (void) Scrollviewdidscroll: (Uiscrollview *) ScrollView { A//Called when scrolling the}
4. Set the zoom of the picture:
//Enlarge Image//1, set zoom in multiples of zoom//Minimun min//Maximun Max//set the maximum multipleSelf.scrollView.maximumZoomScale =Ten; //set the minimum multipleSelf.scrollView.minimumZoomScale =1; //This method tells me to zoom in on that one control-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) ScrollView {return[ScrollView Viewwithtag:1024x768];}
5. Common Properties for page numbers:
1 //Set Total pages2Self.pageControl.numberOfPages =Self.imgcount;3 //where to start the settings4Self.pageControl.currentPage =0;5//set the color of the current page number6Self.pageControl.pageIndicatorTintColor =[Uicolor Bluecolor];7 //set the color of other page numbers8Self.pageControl.currentPageIndicatorTintColor =[Uicolor Redcolor];9 Ten //record the width of the current ScrollView One Scrollview.contentoffset.x A //calculate when the picture scrolls more than half a bit, let the page number jump to the next -Nsinteger PageIndex = (scrollview.contentoffset.x + scrollView.bounds.size.width/2)/scrollView.bounds.size.width;
Simple Judgment Statements can be implemented using the three-mesh operator . In the three mesh operator , do not use + + +1 is good
1 1 0 1;
6. Control the automatic scrolling of pictures:
Need to set a timer to let the page automatically scroll setcontentoffset:animated:
Once the timer is created , it would have been executed , and if he wanted to stop it, he would have to be destroyed . If you want to do this, create a
1 // turn on the timer: 2 Nstimer *timer = [Nstimer scheduledtimerwithtimeinterval: Time target: Operation who selector: method to manipulate UserInfo: Pass parameter repeats: repeat] ; 3 // Stop Timer 4 [timer incaledate];
the execution of each program is like painting, if you let him execute two threads at the same time, he will go first to execute the main thread, our previous thread will stop, so we change his running loop
1 // Modifying the mode of the timer execution code 2 // get main run cycle 3 nsrunloop *runloop = [Nsrunloop mainrunloop]; 4 [Runloop AddTimer:self.timer formode:nsrunloopcommonmodes]; 5 6 Nsdefaultrunloopmode By default Yes 7 Nsrunloopcommonmodes getting the main run cycle
Introduction and use of Uiscrollview: