2013-08-19 23 views
0

我有一個表格視圖,不知道當用戶按下其中一個單元格時如何訪問行號。表視圖的數據是一個小數組,這是最接近的我可以來...在IB中,我控制拖動可重用單元格視圖控制器我推,它工作正常。我不確定如何獲得有條件這樣的行數...製作表格視圖的條件buttonpress

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath 
{ 
// A bunch of stuff is before this, but not important to the question 
//-- > This line if([indexPath row] == 1) This doesn't work... any ideas? 
{ 
    if(totalPoints < 10 && number != 0) 
    { 
     [self saveNumber:@"1"]; 
    } 
    else if (totalPoints < 10 && attachment == 0) 
    { 
     [self saveData:@"1"]; 
     int newPnts = totalPoints + 1; 
     [self savePoints:[NSString stringWithFormat: @"%d", newPnts]]; 
    } 

感謝

+1

你試過'indexPath.row'? – aroth

+0

是的,但它仍然不起作用它很奇怪 – V2Krazy

+0

indexPath.row應該工作。在你嘗試的地方顯示代碼。 – rdelmar

回答

1

它應該工作

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     NSLog(@"%@",indexPath.row); 

     if(indexPath.row==1) 
     { 
      NSLog(@"Do Somthing.."); 
     } 
     else 
     { 
      NSLog(@"Do Somthing.."); 
     } 

} 
+0

謝謝我創建了一個虛擬項目,這工作,所以它是我的數據同步錯誤,然後... – V2Krazy

+0

我的樂趣夥計.. –

1

行編號爲[indexPath行。在tableview中你有一個數據源,其保存用於重載表中的數據陣列

0

好吧,我做錯了什麼其他地方的視圖控制器不從保存的數據更新的標籤。我會發佈一個單獨的問題,如果你有興趣