Grouped Table View - Realizing which cell was selected
I am making a grouped a table view with multiple sections (using NSArrays). Anyway, normally, if I have a regular table view with NO sections I am able to use the following code to realize which cell the user tapped. This no longer works since I use NSArrays to split up the table and don't place the cell names directly into the table view code ([tblSimpleTable addObject:@"cell 1"];
<-- I don't do that).开发者_如何转开发 What new code should I use?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[tblSimpleTable objectAtIndex: indexPath.row] isEqual:@"iPhone"]) {
If you know the Row number and the section number
Try something like this
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section==yoursection)
{
if(indexPath.row==yourRow)
{
//do something
}
}
}
精彩评论