---
title: "Handling Button Clicks Events"  
description: "Here we will see how to code and handle the UIButton events."  
author: "Tarun Kumar"  
published: 2015-11-29  
updated: 2026-05-13  
canonical: https://www.mindstick.com/articles/11928/handling-button-clicks-events  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# Handling Button Clicks Events

Previously, we learn to how to set [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) in iOS appdevelopment:Buttons in iOS\

Now, we will see how to write code that is triggered by a buttonclick. We can handle click events in different ways at the time whenever userclicks on a UIButton.

Here we are describing some different ways to [handle events](https://www.mindstick.com/forum/157865/how-does-knockoutjs-handle-events-and-event-binding) likeusing [anonymous](https://www.mindstick.com/forum/34712/what-is-anonymous-methods-functions-and-lambda-expressions-in-c-sharp) [delegate](https://www.mindstick.com/articles/777/delegate-and-event-in-c-sharp), using [lambda expression](https://www.mindstick.com/articles/897/lambda-expression-in-c-sharp), and some other ways.

##### Use following codes to handle events:

##### \
By using Anonymous delegate:

```
buttonObj1.TouchUpInside += delegate {          new UIAlertView(“Clicked Button1”, “Using TouchUpInside”,                                          null, “OK”, null).Show();};
```

By using Lambda expression:\

```
buttonObj2.TouchUpInside += (sender, ea) => {          new UIAlertView(“Clicked Button2”, “Using TouchUpInside”,                                           null, “OK”, null).Show();};
```

By assigning a delegate method:\

```
buttonObj3.TouchUpInside += HandleTouchUpInside;
```

By adding a method:

```
void ButtonEventFired(object sender, EventArgs ea) {         new UIAlertView(“Clicked Button3”, “Using TouchUpInside”,                                           null, “OK”, null).Show();}
```

We can use a different number of events fired by the user using UIButton.

##### Here are some of them:

TouchUpInside event : this event will occur when the user performs a touch [operation](https://yourviews.mindstick.com/view/83916/why-is-it-necessary-to-sterilize-operation-theater) which Begins & Ends inside the bounds of the UIButton.

TouchUpOutside event : this event will occur when the user Begins a touch inside the UIButton but lifts their finger outside its bounds.

TouchDown event : this event will occurs as soon as a touch starts in the button, regardless of where the touch ends.

(Mostly ‘TouchUPInside’ UIButton event is used for responding the user interation.)

Next, we will learn how to set Image on UIButton on different [states](https://answers.mindstick.com/qa/95510/india-has-collaborated-with-which-country-to-create-150-villages-of-excellence-in-12-states-of-india) :[Setting UIImage on a UIButton](https://www.mindstick.com/Blog/10992/setting-uiimage-on-a-uibutton)

---

Original Source: https://www.mindstick.com/articles/11928/handling-button-clicks-events

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
