A Pagecontrol presents user with a set of horizontal dots representing pages.The current page is presented as white dot.We can navigate to the next or previous pages.In this example we will create a page control with displaying page number.
- Create a new project as, Create a new Xcode project –>Single View Application
- Enter the Product name as PageControlExample.This will be your project name.
- Enter Organization name,company identifier,bundle identifier and check use Automatic Reference counting.Uncheck the use Storyboard option.
- Drag and drop the UIPageControl in the .xib file.It looks like,
- ctrl+drag from pagecontrol to interface section to create an outlet.
- Drag and drop a label in the .xib file and create an outlet like we did before.
- create an action for the pagecontrol and name it as changePage,
Now add this lines inside the changePage method ,
self.pageNumber.text = [NSString stringWithFormat:@"%i", ([self.pageControl currentPage]+1)];
Congratulation ! Finally…