heightForRowAtIndexPath
そのセル内のビューを非表示および表示する関数を呼び出そうとしていますが、不本意ながら無限ループを作成しました。何が問題なのか、どうすれば解決できるのかを指摘してください。
で機能する heightForRowAtIndexPath
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"indexrow = %ld \n pre = %d\n sel = %d \n",(long)[indexPath row],previousselectedcell,selectedcell);
if([indexPath row] == previousselectedcell){
return 60;
}
else if ([indexPath row] == selectedcell) {
NSLog(@"height toggle= %@",toggle);
[self ViewToggle:tableView IndexPath:indexPath Do:@"true"];
return 180;
}
else
{
return 60;
}
}
関数定義
-(void)ViewToggle:(UITableView *)tableView IndexPath:(id)myindexPath Do:Toggle{
InterestTableViewCell *cell = (InterestTableViewCell *) [tableView cellForRowAtIndexPath:myindexPath];
if([Toggle isEqualToString:@"true"]){
cell.ContainerView.hidden=NO;
}
else{
cell.ContainerView.hidden=YES;
}
}
問題はここにあります
InterestTableViewCell *cell = (InterestTableViewCell *) [tableView cellForRowAtIndexPath:myindexPath];
テーブルからセルを取得しようとしています。しかし、セルはまだ作成されていません。だからあなたは細胞の作成に戻ります
heightForRowAtIndexPathは、セルの内容を構成するのに適した場所ではありません。tableView:didSelectRowAtIndexPath:メソッドで実行することをお勧めします
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加