2016-08-11 2 views
0

を却下しないように:Q:カスタムTableViewCellスクロール見て、再び表示され、私のカスタムラインは、最初のセルでは、私は、システムのセルラインの下のカスタムセルの行を追加し、私は私の<code>tableview</code> 2つの異なる<code>custom cell</code>を持って

_bottom_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, kScreen_Width, 1)]; 
_bottom_line.backgroundColor = Back_Color_QQ; 
[part3 addSubview:_bottom_line]; 

controllerでカスタムセルを設定しています。

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

    if (indexPath.section == 0) { // my first cell 

     static NSString *id_cell1 = @"cell1"; 
     AgDetailTechCell *cell = [tableView dequeueReusableCellWithIdentifier:id_cell1]; 
     if (cell == nil) { 
      cell = [[AgDetailTechCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:id_cell1]; 
     } 

     ((AgDetailTechCell *)cell).model = self.headerModel; 
     ((AgDetailTechCell *)cell).indexPath = indexPath; 
     ((AgDetailTechCell *)cell).delegate = self; 
     _head_cell = cell; 

     _head_cell.comemntCountlabel.text = self.headerModel.lml_commentTimes; 
     _head_cell.likeCountlabel.text = self.headerModel.lml_likeTimes; 

     return cell; 
    }else { // other cells 

     static NSString *id_cell2 = @"cell2"; 
     AgPreOrHelpCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:id_cell2]; 
     if (cell == nil) { 
      //cell = [[AgPreOrHelpCommentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:id_cell2]; 
      cell = [[NSBundle mainBundle] loadNibNamed:@"AgPreOrHelpCommentCell" owner:self options:nil].firstObject; 
     } 
     cell.delegate = self; 
     cell.indexPath = indexPath; 
     [cell initCellDataWithModel:self.dataSource[indexPath.row]]; 


     cell.refresh = ^(UITableViewCell *currentCell) { 


      [self.tableView reloadData]; 

      [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; 

     }; 


     return cell; 
    } 

} 

コントローラにはじめて表示されます。しかし、私がtableviewをスクロールして再び表示して表示すると、自分の最終行が消えてしまいます。見つけられません。また、テーブルビューを更新すると、カスタム行が再び表示されます。私は、詳細を説明するためのトークン2枚の写真を持って:

First time into the controller it shows well After scroll my tableview and show the line ,it dismss

UPDATE 利用厳しいの提案が、問題の変更なし:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 

    if ([cell.reuseIdentifier isEqualToString:@"cell1"]) { 
     // customs bottom_line 
     UIView * bottom_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, kScreen_Width, 1)]; 
     bottom_line.backgroundColor = Back_Color_QQ; 

     [((AgDetailTechCell *)cell).part3 addSubview:bottom_line]; 
    } 

} 
+0

は 'willDisplayCell' DataSourceメソッドで行を追加してみてください。私はあなたが正しい結果を得ることを願っています。 – Harsh

+0

@Harsh私はあなたの提案をしましたが、変化がないことを常に示しています。 – aircraft

+0

あなたが話しているラインを画像でハイライトすることができますか? – Harsh

答えて

0

たぶん、あなたの一番下の行は、外にありますあなたの細胞。細胞の高さが50以上であることを確認してください。もう一つは、UITableViewのシステムボトムラインを無効にすることです。

+0

私は 'lldb'セルを持ち、その高さは変更されておらず、' view hierarchy'をキャプチャしています。私の 'custom bottom line'は表示されません。 – aircraft

+0

スーパービューから一番下の行が削除されましたか?あなたはこの問題のデモプロジェクトを作るのがよいでしょう。それから私たちはそれをデバッグすることができます。 –

関連する問題