开发者

Grouped Table View - Realizing which cell was selected

开发者 https://www.devze.com 2023-03-19 23:19 出处:网络
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

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
    }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消