我有一个UITableView节。如果我点击一个单元格,按预期触发didSelectRowAtIndexPath。但如果tableview的行数多于可以在单个屏幕中显示的行数,并且如果我垂直滚动tableview并单击一行,则不会调用didSelectRowAtIndexPath。只有当我再次点击同一行时才会触发它。当你滚动时,桌面浏览器应该如何工作?如果不是,有什么我失踪? 感谢您的任何帮助。滚动UITableView不会调用didSelectRowAtIndexPath
回答
感谢Tim的输入。然而,添加if条件并没有帮助。在nib文件中禁用了滚动功能,从而解决了问题。再次感谢!!
问题是您的cellForRowAtIndexPath使用的出队错误。
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SingleCellIdentifier = @"selectioncell";
UITableViewCell *selectionCell = [tableView dequeueReusableCellWithIdentifier:SingleCellIdentifier];
if(selectionCell == nil)
selectionCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SingleCellIdentifier] autorelease];
[selectionCell setSelectionStyle:UITableViewCellSelectionStyleBlue];
[selectionCell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
[[selectionCell textLabel] setText:[[possibleAnswers objectAtIndex:indexPath.row] answerText]];
}
的想法是,dequeueReusableCellWithIdentifier:
为您提供了一个可用的电池,但如果没有可用的,则返回零;如果它是零,你应该自己分配它。您的代码正在取出已出队的单元格,但忽略它并只是简单地分配而不管出列状态。试试这个,看看它是否能解决你的问题。
我刚刚验证了我的整个项目的这种方法,但找不到任何 – user678229 2012-02-16 22:15:04
好吧,邮编或我们无法帮助你。 – Tim 2012-02-16 22:25:46
将它发布在*问题*中。 – Tim 2012-02-16 22:44:24
- 1. UITableView didSelectRowAtIndexPath调用两次
- 2. Xamarin UITableView不会滚动
- 3. UITableView didSelectRowAtIndexPath
- 4. popupView中没有调用UITableview的didSelectRowAtIndexPath
- 5. UITableView - didSelectRowAtIndexPath问题?
- 6. 的UITableView不会滚动到细胞
- 7. UITableView不会滚动到某个位置
- 8. 双击UITabBarItem不会滚动UITableView顶部
- 9. UITableView不会滚动或选择
- 10. 配置的UITableView不会滚动iPhone
- 11. 的UITableView不会滚动到底(SWIFT IOS)
- 12. DidSelectRowAtIndexPath不被调用
- 13. UITableView不滚动使用UISearchBar
- 14. 滚动/调整大小UITableView
- 15. UITableView didSelectRowAtIndexPath有时只会被解雇
- 16. UITableView - didSelectRowAtIndexPath中的代码不起作用
- 17. 的UITableView在UIPageViewController不能调用方法didSelectRowAtIndexPath方法
- 18. 自定义的UITableView单元格与UIButton不调用didSelectRowAtIndexPath
- 19. UITableView(在UIScrollView内)didSelectRowAtIndexPath:不在第一个水龙头上调用
- 20. iPhone - UITableView不调用3.0 SDK中的didSelectRowAtIndexPath方法
- 21. 在iOS 5 TableViewController没有滚动,也没有调用didSelectRowAtIndexPath
- 22. didSelectRowAtIndexPath在滚动和选择单元格时没有被调用
- 23. 禁用自动滚动UITableView
- 24. UITableView刷新不滚动
- 25. uitableview不滚动到底部
- 26. UITableView iOS11不滚动 - XCode 9
- 27. UITableView与HeaderView不滚动
- 28. iOS UITableView滚动不平滑
- 29. 我的UITableView不滚动
- 30. UITableView Swift不滚动Swift
如果表格仍在滚动,则第一次触摸将停止滚动而不调用didSelectRowAtIndexPath。这是你的意思吗?如果不是,那么请添加更多的描述,也许还有一些相关的代码片段 – jackslash 2012-02-16 21:38:56
我做了一次水龙头停止滚动,然后尝试选择与另一个水龙头什么都没做的行。是否有您想让我发布的特定代码/方法?我所拥有的是一个简单的tableview,大约有20行,我在didSelectRowAtIndexPath方法中有一个断点,它只在我选择了两行之后才被调用... – user678229 2012-02-16 21:54:08
尝试粘贴这一切。也许蒂姆是对的... – jackslash 2012-02-16 21:59:47