Eshwar Chaitanya
Eshwar Chaitanya

Reputation: 942

Alerts for tableview cells

How can we create alerts for cells in tableviews.What are the methods used to implement them

Upvotes: 0

Views: 77

Answers (1)

Rui Peres
Rui Peres

Reputation: 25907

Alerts? You need to be more specific. If you are talking about UIAlertView, you can do it like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIAlertView *alert =
    [[UIAlertView alloc] initWithTitle: aTitle
                               message: @"My message"
                              delegate: self
                     cancelButtonTitle: @"OK"
                     otherButtonTitles: nil];
    [alert show];
    [alert release];

}

You are showing an alert when you click a cell. Also notice that you are setting that alertView's delegate as self. So, your class needs to comply with the UIAlerViewDelegate, if you want to add some logic after the user selects a button.

Upvotes: 1

Related Questions