Example
- Double click on the Main.Storyboard file.
- Set View As to iPhone 6:
- Drag a label and a button from the Toolbox to the design surface so that it looks like the image below:
- In the Properties pad, give the label and button the following properties:
nothing | Name | Title |
---|
Label | lblClicks | [blank] |
Button | clickMe | Click Me! |
- Add the following code to the ViewDidLoad method inside the ViewController class:
clickMe.TouchUpInside += (sender, e) =>
{
totalClicks++;
if (totalClicks == 1)
{
lblClicks.Text = totalClicks + " Click";
}
else {
lblClicks.Text = totalClicks + " Clicks";
}
};
- Run the application