Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/UIKit.framework |
Availability | Available in iOS 2.0 and later. |
Declared in | UIPageControl.h |
You use the UIPageControl
class to create and manage page controls. A page control is a succession of dots centered in the control. Each dot corresponds to a page in the application’s document (or other data-model entity), with the white dot indicating the currently viewed page.
For an example of a page control, see the Weather application (with a number of locations configured) or Safari (with a number of tab views set).
When a user taps a page control to move to the next or previous page, the control sends the UIControlEventValueChanged
event for handling by the delegate. The delegate can then evaluate the currentPage
property to determine the page to display. The page control advances only one page in either direction.
currentPage
property
numberOfPages
property
hidesForSinglePage
property
For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.
The current page, shown by the receiver as a white dot.
@property(nonatomic) NSInteger currentPage
The property value is an integer specifying the current page shown minus one; thus a value of zero (the default) indicates the first page. A page control shows the current page as a white dot. Values outside the possible range are pinned to either 0 or numberOfPages
minus 1.
UIPageControl.h
A Boolean value that controls when the current page is displayed.
@property(nonatomic) BOOL defersCurrentPageDisplay
Set the value of this property to YES
so that, when the user clicks the control to go to a new page, the class defers updating the page indicator until it calls updatePageIndicator
. Set the value to NO
(the default) to have the page indicator updated immediately.
UIPageControl.h
A Boolean value that controls whether the page indicator is hidden when there is only one page.
@property(nonatomic) BOOL hidesForSinglePage
Assign a value of YES
to hide the page indicator when there is only one page; assign NO
(the default) to show the page indicator if there is only one page.
UIPageControl.h
The number of pages the receiver shows (as dots).
@property(nonatomic) NSInteger numberOfPages
The value of the property is the number of pages for the page control to show as dots. The default value is 0.
UIPageControl.h
Returns the size the receiver’s bounds should be to accommodate the given number of pages.
- (CGSize)sizeForNumberOfPages:(NSInteger)pageCount
The number of pages to fit in the receiver’s bounds.
The minimum size required to display dots for the page count.
Subclasses that customize the appearance of the page control can use this method to resize the page control when the page count changes.
UIPageControl.h
Updates the page indicator to the current page.
- (void)updateCurrentPageDisplay
This method updates the page indicator so that the current page (the white dot) matches the value returned from currentPage
. The class ignores this method if the value of defersPageIndicatorUpdate
is NO
. Setting the currentPage
value directly updates the indicator immediately.
UIPageControl.h
Last updated: 2008-06-05