Alerts for tableview cells
How can we create alert开发者_运维问答s for cells in tableviews.What are the methods used to implement them
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.
精彩评论