ios - 按下 UITableViewCell 内的按钮时的 scrollToRowAtIndexPath

标签 ios objective-c uitableview uibutton

我有一个带有一些自定义单元格的表格 View 。第一个里面是一个按钮。当按下这个按钮时,我想滚动到我的表格 View 中的某个部分。我如何必须将按钮操作与 tableview 链接?

最佳答案

您可以使用此功能滚动到某个部分:

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated

使用示例是:
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:5 inSection:indexPath.section] 
             atScrollPosition:UITableViewScrollPositionMiddle animated:NO];

并将按钮操作与 tableview 链接,您可以在自定义单元格中使用协议(protocol)

关于ios - 按下 UITableViewCell 内的按钮时的 scrollToRowAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16884926/

相关文章:

ios - 将 NSNumber 转换为 long

iphone - UITableView中的静态图片

ios - 从 UITableView(WEPopover) 触发 UIViewController 的更改

ios - NSArray 返回 null iOS Objective C

objective-c - 将 UIView 作为 subview 添加到 UITableViewController 的 View 中

ios - 为什么我的表格 View 在滚动到底部后消失了?

ios - CellForRowAtIndexPath 不工作

ios - Swift:我在 "Unexpectedly found nil "中得到了 "tableView.delegate=self"

ios - 立即创建 iPhone 应用程序,并计划稍后支持 iPad

ios - Pod install private pods URI::InvalidURIError - 错误的 URI(不是 URI?)