The application app usually has a guide page, which can be used as a guide to guide the user, or it can be presented to the user to understand the function of the app. Guide page making simple, generally only need a set of pictures, and then show the picture group can be. The Display Picture group is commonly used Uiscrollview to display the page, and is controlled by the Uipagecontrol page controller to display the current page. The Uiscrollview and Uipagecontrol collocation will be more perfect to show the function of the Guide page.
- 1
Create Project and view controllers
1, create a project, a new Uiviewcontroller;
2, select the project, right-click-new File ... Select "Cocoa Touch Class"-next, give a reasonable name Viewcontroller, then Next complete;
3, in the APPDELEGATE.M file contains #import "ViewController.h";
4. Initialize the view controller that created the Viewcontroller and include it with the navigation bar controller. Set it to the root view controller.
- 2
Create Uiscrollview and add proxies
1. Add Event agent and data source agent in ViewController.h <UITextFieldDelegate>;
2, in ViewController.h create Uiscrollview, Uipagecontrol;
3, in VIEWCONTROLLER.M initialization Uiscrollview, Uipagecontrol;
4, Agent authorization and add to the view;
5, repair ScrollView offset.
- 3
Setting the properties of a Uiscrollview
1, set whether there is rubber band effect properties: bounces;
2, set whether to use the paging property: pagingenabled;
3, set whether to allow scrolling properties: scrollenabled;
4, set whether to display the horizontal scroll bar properties: showshorizontalscrollindicator;
5, set whether to display the vertical scroll bar properties: showsverticalscrollindicator;
6. Set content Range Properties: Contentsize.
- 4
Add Uiscrollview proxy methods
1, complete scrolling: scrollviewdidscroll
2, going to start dragging: scrollviewwillbegindragging;
3, end drag: scrollviewdidenddragging
4, Scrolling will begin to slow down: scrollviewwillbegindecelerating;
5, rolling deceleration to stop: scrollviewdidenddecelerating.
6, scroll to the top: scrollviewshouldscrolltotop;
7, Scroll to top: scrollviewdidscrolltotop.
- 5
Set pagination scrolling effect
1. Create an array that initializes the Nsarray to be loaded into each page;
2. Enable Paging properties: pagingenabled = YES;
3, for each page to add array data, for loop traversal;
4, according to Nsarray size set content range: Contentsize;
5, set the total number of pages Uipagecontrol: numberofpages = [array count];
6, set Uipagecontrol the current page: CurrentPage.
- 6
Uipagecontrol also follows the change when configuring paging scrolling
1, Add Uiscrollview Agent method: Scrollviewdidscroll
2, within the scrollviewdidscroll to achieve the monitoring Contentoffset content offset;
3, according to Contentoffset calculate which page is currently belong to;
4. Assign value to Self.pageControl.currentPage.
END
Code