Page Flip Controller control: Uipageviewcontroller
Introduction:
1, it is to provide us with a similar to the book effect of a control. We can use the Uipageviewcontroller control to accomplish similar book-like page control. With page View, users can easily navigate through multiple pages through gestures.
2, First illusion, a book can be divided into: 1. Each page. 2. The corresponding data in each page. using the Uipageviewcontroller control is also a similar two component. To have a book frame to control the page, the content of each page. Create a viewcontroller that contains a uipageviewcontroller to control the display, and a nsarray includes all the data. Define this Viewcontroller class and use Uipageviewcontroller to manage each page and provide the data. 3, can only add 1 Pagecontentviewcontroller as the content of multiple pages, because the boot page is very similar, by reusing this view controller is obviously a better choice.
Type:
※ Navigation Direction enumeration
typedef ns_enum (Nsinteger, uipageviewcontrollernavigationorientation) {
Uipageviewcontrollernavigationorientationhorizontal = 0, //Horizontal
uipageviewcontrollernavigationorientationvertical = 1 //Vertical
};
※ Spine Position enumeration, determines the number of views displayed on the first page
typedef ns_enum (Nsinteger, uipageviewcontrollerspinelocation) {
Uipageviewcontrollerspinelocationnone = 0, //No spine, scroll display view
Uipageviewcontrollerspinelocationmin = 1, //spine left or up, home display a view
Uipageviewcontrollerspinelocationmid = 2, //Spine Center, home display two views
Uipageviewcontrollerspinelocationmax = 3 //spine right or bottom, display a view
};
※ Page Flipping Mode enumeration
typedef ns_enum (Nsinteger, uipageviewcontrollernavigationdirection) {
Uipageviewcontrollernavigationdirectionforward, //page from left to right (or bottom to top)
Uipageviewcontrollernavigationdirectionreverse //page from right to left (or from top down)
};
※ Flip Style Enumeration
typedef ns_enum (Nsinteger, Uipageviewcontrollertransitionstyle) {
Uipageviewcontrollertransitionstylepagecurl = 0, //flip book effect style
Uipageviewcontrollertransitionstylescroll = 1 //Slide effect style
};
Image Relationship:
detailed properties and methods:※ Initialize, build Uipageviewcontroller instance-(Instancetype) Initwithtransitionstyle: (Uipageviewcontrollertransitionstyle) style navigationorientation: ( uipageviewcontrollernavigationorientation) navigationorientation options: (nsdictionary *) options;
Description
The Uipageviewcontrollertransitionstyle enumeration type defines the following two rollover styles.
Uipageviewcontrollertransitionstylepagecurl: Book effect style.
Uipageviewcontrollertransitionstylescroll: Slide effect style.
Navigationorientation sets the page turn direction, the Uipageviewcontrollernavigationdirection enumeration type defines the following two ways to flip.
Uipageviewcontrollernavigationdirectionforward: From left to right (or from bottom to top);
Uipageviewcontrollernavigationdirectionreverse: Right-to-left (or top-down).
※ used to set the view displayed in the homepage-(void) Setviewcontrollers: (Nsarray *) viewcontrollers direction: (uipageviewcontrollernavigationdirection) Direction animated: (BOOL) animated completion: (void (^) (bool finished)) completion;Description:
The
first page shows several views related to the spine type, and if it is uipageviewcontrollerspinelocationmin or Uipageviewcontrollerspinelocationmax, a view is displayed on the first page. If it is uipageviewcontrollerspinelocationmid, two views are displayed on the home page.
※ Controller Agent@property (nonatomic, assign) ID <UIPageViewControllerDelegate> delegate;※ Controller Data source@property (nonatomic, assign) ID <UIPageViewControllerDataSource> dataSource;※ Flip Style@property (nonatomic, readonly) Uipageviewcontrollertransitionstyle Transitionstyle;※ Direction of page flipping@property (nonatomic, readonly) uipageviewcontrollernavigationorientation navigationorientation;※ Spine Position@property (nonatomic, readonly) uipageviewcontrollerspinelocation spinelocation;※ Recognition gesture Array@property (nonatomic, readonly) Nsarray *gesturerecognizers;※ Controller Array@property (nonatomic, readonly) Nsarray *viewcontrollers;※ Double-sided display@property (nonatomic, getter=isdoublesided) BOOL doublesided; Proxy Method:
@protocol uipageviewcontrollerdelegate <NSObject>
@optional
※ The method that is triggered when the gesture-initiated gesture starts.
-(void) Pageviewcontroller: (Uipageviewcontroller *) Pageviewcontroller willtransitiontoviewcontrollers: (NSArray *) Pendingviewcontrollers;
※ This method is called when the user moves from one page to the next or to the previous page, or when the user begins to regret the move from one page to another, and then revokes back to the previous page. If the successful jump to another page, transitioncompleted will be set to YES, if the jump on the way to cancel the jump this action will be placed into NO.
-(void) Pageviewcontroller: (Uipageviewcontroller *) Pageviewcontroller didfinishanimating: (BOOL) finished Previousviewcontrollers: (Nsarray *) previousviewcontrollers transitioncompleted: (BOOL) completed;
※ This method will be called when the direction of the device changes. You can use this method to set the position of the page primary key by returning a value of the location type of the UIPAGEVIEWCONTROLLERSPI.
-(Uipageviewcontrollerspinelocation) Pageviewcontroller: (Uipageviewcontroller *) Pageviewcontroller Spinelocationforinterfaceorientation: (uiinterfaceorientation) orientation;
※ The number of page content controllers returned to the controller in the page controller
-(Nsuinteger) Pageviewcontrollersupportedinterfaceorientations: (Uipageviewcontroller *) PageViewController;
※ return to set the spine position
-(Uiinterfaceorientation) Pageviewcontrollerpreferredinterfaceorientationforpresentation: (UIPageViewController * ) Pageviewcontroller;
Data source methods:
@required (methods that must be implemented)
※ Return to the previous controller
-(Uiviewcontroller *) Pageviewcontroller: (Uipageviewcontroller *) Pageviewcontroller Viewcontrollerbeforeviewcontroller: (Uiviewcontroller *) Viewcontroller;
※ After returning the controller
-(Uiviewcontroller *) Pageviewcontroller: (Uipageviewcontroller *) Pageviewcontroller Viewcontrollerafterviewcontroller: (Uiviewcontroller *) Viewcontroller;
@optional (Optional method)
※ Returns the number of pages in the page controller
-(Nsinteger) Presentationcountforpageviewcontroller: (Uipageviewcontroller *) Pageviewcontroller;
※ Returns the index of the current page in the page controller
-(Nsinteger) Presentationindexforpageviewcontroller: (Uipageviewcontroller *) Pageviewcontroller;
Ios:uipageviewcontroller Page Controller Controls detailed introduction