2012-02-09 17 views
0

iPhoneアプリケーションを開発していて、グループ化されたテーブルビューのセクションを確認する際に問題があります。私がtableviewをスクロールして、最初のセクションがもう見えなくなり、tableviewが戻ってくると、2番目のセクションは最初のセクションから設定を取得しますか?私はそれがindexPath.section値を持つセクションをチェックします。これをどうすれば解決できますか?申し訳ありませんが私の英語が正しくない場合!前のセクションが画面外になったときのUITableViewセクションiPhone

申し訳ありませんコードが不足しています。ここ はcellForRowAtIndexPathコードの一部です:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault   reuseIdentifier:CellIdentifier]; 
    } 
    if(indexPath.section == 0){ 
     pinSwitch.hidden = YES; 
    cell.imageView.image = [UIImage imageNamed:@"test_item.png"]; 
    if([headarray count] != 0){ 
     if(indexPath.row > [headarray count] - 1){ 
      cell.imageView.alpha = 0; 
      cell.textLabel.text = [NSString stringWithFormat:@"Add new",indexPath.row + 1]; 

     } 
     else{ 
      cell.imageView.alpha = 1; 
      NSArray *infoarray = [headarray objectAtIndex:indexPath.row]; 
      cell.textLabel.text = [infoarray objectAtIndex:0]; 
     } 
    } 
} 
    else if(indexPath.section == 1){ 


    if(indexPath.row == 0){ 
//some more cell data 
} 

私は、これは私の問題を表示するのに十分であるべきだと思います!

+0

: コードが一杯になっていないが、私はあなたがこのような何かを行うべきだと思いますbit diffuse..provideいくつかのコードを説明し、あなたは何をしようとしていますか? – Stas

+0

具体的には、あなたが 'cellForRowAtIndexPath:'を見せることができれば、それを理解できるはずです。 – yuji

答えて

0
細胞生成のための

ペーストコード、あなたは正しくリユース細胞メカニズムに

EDIT使用されていないようです:あなたの質問は、Aである

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault   reuseIdentifier:CellIdentifier]; 
    } 
    if(indexPath.section == 0){ 
     pinSwitch.hidden = YES; 
    cell.imageView.image = [UIImage imageNamed:@"test_item.png"]; 
    if([headarray count] != 0){ 
     if(indexPath.row > [headarray count] - 1){ 
      cell.imageView.alpha = 0; 
      cell.textLabel.text = [NSString stringWithFormat:@"Add new",indexPath.row + 1]; 

     } 
     else{ 
      cell.imageView.alpha = 1; 
      NSArray *infoarray = [headarray objectAtIndex:indexPath.row]; 
      cell.textLabel.text = [infoarray objectAtIndex:0]; 
     } 
    } 
} 
    else if(indexPath.section == 1){ 
     if(indexPath.row == 0){ 
    // you should fill cell data for all cases !!!! 
    } 
} else { // for example 
      cell.imageView.alpha = 1; 
      NSArray *infoarray = [headarray objectAtIndex:indexPath.row]; 
      cell.textLabel.text = [infoarray objectAtIndex:0]; 
} 
+0

私はいくつかのコードを追加しました – kjeldGr

+0

はい私はそれをしました!誤解をおかけして申し訳ありません!私はすべての細胞のデータを埋める!第1のセクションが見えない場合、第2のセクションのセルは、第1のセクションのいくつかのセルデータを取得する – kjeldGr

関連する問題