次のメソッドは、配列からUITableViewのカスタムセルにデータを読み込みます。データは正しく読み込まれます。しかし、上記のセルのデータをスクロールダウンすると(セルは表示されません)、配列内の一見ランダムな要素に変更されます。最初に正しく読み込まれたUITableViewセル
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
cellComments=nil;
cellComments=(FullCommentCell *)[tableView dequeueReusableCellWithIdentifier:FullCommentCell_ID];
if(cellComments==nil)
{
[[NSBundle mainBundle]loadNibNamed:@"FullCommentCell" owner:self options:nil];
}
NSString *row = [NSString stringWithFormat:@"#%i",indexPath.row+1];
[cellComments loadFullComments:[latestFMLComments objectAtIndex:(indexPath.row+1)] withCommentNumber:row];
//cellComments.userInteractionEnabled=NO;
return cellComments;
}
また、セルをクリックすると次の方法で処理されます。セルのデータが配列内の何らかのランダムな要素に変わったとき - 私が(以下のメソッドを呼び出す)セルをクリックすると、セルのデータが正しいデータに変更されます。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self tableView:tableView cellForRowAtIndexPath:indexPath];
}
これが起こっている理由は何ですか?
サブビュー要素をリセットするとどういう意味ですか? – zpesk