uipageviewcontroller book

uipageviewcontroller book

uia book rom

Uipageviewcontroller Book

CLICK HERE TO CONTINUE




Purchase the fully updated iOS 10 / Swift 3 / Xcode 8 edition of this book in eBook ($19.99) or Print ($45.99) format.iOS 10 App Development Essentials Print and eBook (ePub/PDF/Kindle) edition contains over 100 chapters. The UIPageViewController class was introduced into the iOS 5 SDK as a mechanism to implement a page turning style of user interface in iOS applications. This chapter will provide a brief overview of the concepts behind the page view controller before working through the development of an example application in the next chapter. The UIPageViewController class highlights the distinction between a view controller and a container controller. A view controller is responsible for managing a user interface view, typically in the form of a view hierarchy contained within an Interface Builder NIB file. Creating a Single View Application with Xcode, for example, will create a single view controller class with a corresponding .xib Interface Builder file. A container controller, on the other hand, is a class designed to contain and manage multiple view controllers, usually providing a mechanism for switching from one view controller to another, either programmatically or in response to user interaction.




The UIPageViewController class is a container controller designed to facilitate navigation through multiple views using a page curling visual transition. When implemented, this allows users to page through content using screen based gestures, much in the same way Apple’s iBooks application allows a user to move backwards and forwards within the pages of an eBook using page turning gestures. Each page displayed to the user is actually a view controller created on demand for the page controller by a data source. In order to function, a UIPageViewController instance must be assigned a data source which, in turn, is responsible for providing view controller objects as required for each page. The data source takes the form of a class instance that implements the protocol which, at a minimum, must implement the following two methods: The mechanism used to create the requested view controllers and the content therein will generally be application specific and is at the discretion of the developer.




Apple does, however, recommend that in order to ensure optimal performance and minimal resource usage, the view controllers be created on an as-needed basis rather than pre-created. When a UIPageViewController object is initialized a number of configuration options may be specified to configure the appearance and behavior of the contained views. The page controller is capable of transitioning between views using either a vertical or horizontal paradigm. In the case of horizontal navigation, page transitions take place in the same way pages are turned in a physical book by sweeping a finger on the screen either left or right. In the case of horizontal navigation, pages are turned by making vertical gestures in much the same way the pages of a wall calendar are flipped. These options are configured using the following constants: The UIPageViewController class allows for the location of the spine to be configured. The term spine in this context is analogous to the spine of a book and dictates the location of the axis on which each page will turn.




The behavior of the spine location settings vary depending on the navigation orientation setting. For example, the default for most configurations is UIPageViewControllerSpineLocationMin which places the spine on the left hand side or top of the screen depending on whether the navigation orientation is horizontal or vertical. Similarly, the UIPageViewControllerSpineLocationMax setting will position the spine at the right or bottom edge of the display. In order to display two pages simultaneously the UIPageViewControllerSpineLocationMid setting should be used. The view controller may also be configured to treat pages as being double sided via the doubleSided property. Note that when using UIPageViewControllerSpineLocationMid spine location it will be necessary to provide the page controller with two view controllers (one for the left hand page and one for the right) for each page turn. Similarly, when using either the min or max spine location together with the double sided setting, view controllers for both the front and back of the current page will be required for each page.




In addition to a data source, instances of the UIPageViewController class may also be assigned a delegate which, in turn, may implement the following delegate methods: The UIPageViewController class is categorized as a container controller in that it is responsible for containing view controllers and managing which view is displayed to the user. The main purpose of the UIPageViewController is to allow the user to navigate through different views using a page curl transition style. Implementation of this functionality requires the configuration of navigation orientation, spine location and a number of data source methods. The theory covered in this chapter will be put into practice in the next chapter entitled An Example iOS 5 iPhone UIPageViewController Application.UIPage​View​ControllerA page view controller lets the user navigate between pages of content, where each page is managed by its own view controller object. Navigation can be controlled programmatically by your app or directly by the user using gestures.




When navigating from page to page, the page view controller uses the transition that you specify to animate the change. LanguageObjective-CSDKsOverviewWhen defining a page view controller interface, you can provide the content view controllers one at a time (or two at a time, depending upon the spine position and double-sided state) or as-needed using a data source. When providing content view controllers one at a time, you use the set​View​Controllers(_:​direction:​animated:​completion:​) method to set the current content view controllers. To support gesture-based navigation, you must provide your view controllers using a data source object.The data source for a page view controller is responsible for providing the content view controllers on demand and must conform to the UIPage​View​Controller​Data​Source protocol. The delegate object—an object that conforms to the UIPage​View​Controller​Delegate protocol—provides some appearance-related information and receives notifications about gesture-initiated transitions.




This class is generally used as-is but may be subclassed in iOS 6 and later.SymbolsCreating Page View Controllers(Initializes a newly created page view controller.The object that provides view controllers.Providing ContentSets the view controllers to be displayed.The view controllers displayed by the page view controller.An array of UIGesture​Recognizer objects that are configured to handle user interaction.Display OptionsThe direction along which navigation occurs.The location of the spine.The style used to transition between view controllers.A Boolean value that indicates whether content appears on the back of pages.ConstantsUIPage​View​Controller​Navigation​OrientationOrientations for page-turn transitions.UIPage​View​Controller​Navigation​DirectionDirections for page-turn transitions.UIPage​View​Controller​Transition​StyleStyles for the page-turn transition.Options KeysKeys for the options dictionary.UIPage​View​Controller​Spine​LocationLocations for the spine.

Report Page