UITableView在第一次加载时不响应滚动

编程入门 行业动态 更新时间:2024-10-26 20:26:55
本文介绍了UITableView在第一次加载时不响应滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我发现,第一次加载UITableView时,它不会对滚动触摸做出响应-如果它的行数不超过屏幕显示的容量.如果我关闭视图,则重新打开相同的对象-现在它会响应触摸-即使它包含相同数量的行.

I have found that the first time a UITableView loads, it does not respond to scrolling touches -- if it does not have more rows than fit on the screen. If I close the view, then reopen the same object -- it will now respond to touches -- even though it contains the same number of rows.

除了对行数响应UITableViewDataSource方法并自行生成行外,我没有做任何其他事情.每当视图出现时,我都会重新加载表.

I am not doing anything more than responding to the UITableViewDataSource methods for the number of rows, and generating the rows themselves. I am reloading the table every time the view appears.

任何人都可以解释这种行为吗?

Can anyone explain such behavior?

我正在像这样创建单元格:

I am creating the cells like so:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *tableId = @"NewIndexTableId"; Note *note = [notes objectAtIndex:[indexPath row]]; UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:tableId]; if (cell == nil) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableId] autorelease]; cell.textLabel.text = note.text; cell.detailTextLabel.text = [note changedDelta]; cell.accessoryView = multipleAccounts ? [note.account imageView] : nil; return cell; }

推荐答案

我解决了此问题,方法是确保表中始终至少有10行-当实际行数少于10时创建虚拟行.这解决了故障.

I solved this problem by making sure there are always at least 10 rows in the table -- creating dummy rows when there are less than 10 real rows. This solved the glitch.

更多推荐

UITableView在第一次加载时不响应滚动

本文发布于:2023-10-12 21:38:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485971.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   UITableView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!