iOS – UIStepper Example…

UIStepper was introduced in iOS 5.0.It provides an option for the user to increment or decrement values.Now we are going to create a project with UIStepper which displays increment or decrement values.

  • open Xcode and Select Create a new Xcode project –>Single View Application.
  • Enter the product name as ‘UIStepperExample‘,this will remain as your project name.
  • Enter company identifier,organizaton name,bundle identifier.
  • Check option Use Automatic Reference Counting and uncheck option Use Storyboards.


  • Drag and drop the UIStepper and UILabel in the .xib file like,


  • ctrl + drag from UIStepper to interface section to create an outlet for UIStepper and name it as ‘stepperOutlet‘.


  • ctrl+drag from UILabel to interface section to create an outlet for UILabel and name it as ‘stepperLabel‘.


  • ctrl+drag from UIStepper to interface section to create an Action for UIStepper and name it as ‘stepperClicked‘.


  • Now add this code to ViewController.m file inside the ‘viewDidLoad‘ method.

self.stepperOutlet.minimumValue = 0;

self.stepperOutlet.maximumValue = 1000;

self.stepperOutlet.stepValue = 10;

self.stepperOutlet.autorepeat = YES;

self.stepperOutlet.continuous = YES;

self.stepperLabel.text = [NSString stringWithFormat:@"Value:%d",0];

What’s this,

Minimum Value:It is the minimum value the UIStepper will start from.Here we our minimum value is ‘0‘.

Maximum Value:It is the maximum value of the UIStepper can reach.Here our maximum value is ‘1000‘.

Step Value:It is the value by which UIStepper will increment or decrement each time when we press ‘+‘ or ‘‘ button.

Autorepeat:If ‘YES’ the UIStepper will continuously increment or decrement the value when the ‘+‘ or ‘‘ button is press and hold.

Continuous:If ‘YES’ the value change events are send immediately when the user clicks ‘+‘ or ‘‘ button.If ‘NO’ the value changing events are send when the user interaction ends.


  • Now add this code inside the method ‘stepperClicked‘,

int stepperIntValue = self.stepperOutlet.value;
self.stepperLabel.text = [NSString stringWithFormat:@"Value:%d",stepperIntValue];



iOS – UIPageControl example…

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…