当我的“发送”按钮被点击时,我使用下面的代码滚动到我的表格 View 的底部。也就是说,即使我已将动画设置为"is",动画仍显得“断断续续”。 例如当按钮被点击时,我的整个表格 View 内容被清除(变白),然后重新出现在我的表格 View 的底部(相对于我正在寻找的平滑滚动动画?)
ViewController.m
- (IBAction)sendReply:(id)sender {
[self.tableView setContentOffset:CGPointMake(0, CGFLOAT_MAX) animated:YES];
}
最佳答案
在您的按钮操作中调用此scrollTableToBottom
方法
条件用于检查任何行是否存在。你可以忽略它并相应地处理
- (void)scrollTableToBottom {
NSInteger rowNumber = [self. tableView numberOfRowsInSection:0];
if (rowNumber > 0) {
[self. tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:rowNumber-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
}
如果您有任何问题,请告诉我。
快乐编码。
关于ios - 在点击按钮时动画滚动到 tableview 的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40758205/