Uipagecontrol of iOS controls

Source: Internet
Author: User

function: Usually used with Uiscrollview, prompting the user to display the number of pages currently


Common Properties and methods


There are a few pagination "circles"
@property (nonatomic) Nsinteger numberofpages;
Display the current page
@property (nonatomic) Nsinteger currentpage;
If there is only one page, whether it is hidden, the default is Yes
@property (nonatomic) BOOL hidesforsinglepage;
Refresh View

-(void) updatecurrentpagedisplay;


Project:uipagecontroldemo




Open APPDELEGATE.M


In-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions


In the [Self.window makekeyandvisible]; Top Join

Uipagecontrol *pagecontrol = [[Uipagecontrol alloc] initwithframe:cgrectmake (0, 100, 320, 40)];

Pagecontrol.backgroundcolor = [Uicolor Graycolor];
[Self.window Addsubview:pagecontrol];


Run


in Uipagecontrol *pagecontrol = [[Uipagecontrol alloc] initwithframe:cgrectmake (0, 100, 320, 40)]; Add below

Pagecontrol.numberofpages = 10;
Pagecontrol.currentpage = 2;


Run


You can move around by clicking


in pagecontrol.currentpage = 2; Add below

pagecontrol.enabled = NO;


Run

Will pagecontrol.enabled = NO; Comment out Join

[Pagecontrol addtarget:self Action: @selector (change:) forcontrolevents:uicontroleventvaluechanged];


In the Join method


-(void) Change: (Uipagecontrol *) Pagecontrol
{
NSLog (@ "index:%d", pagecontrol.currentpage);
}

Run

Will


Pagecontrol.numberofpages = 10;
Pagecontrol.currentpage = 2;


Switch

Pagecontrol.numberofpages = 1;
Pagecontrol.hidesforsinglepage = yes;//If it's a single page, hide it.


Run

In the real project development time is to customize the control because the small point itself is too small inconvenient operation


Uipagecontrol of iOS controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.