我想像whatsapp一样,首先在表视图中显示最后一个单元格。我不想要滚动动画。有人能帮我吗?感谢
[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO];
请注意:动画没有
您可以通过转换UITableView和您在其中使用的任何视图(包括UITableViewCell)来实现这一点。
首先通过设置转换来反转表视图
tableView.transform = CGAffineTransformMake(1, 0, 0, -1, 0, 0);
然后在cellForRowAtIndexPath中,您需要将相同的转换设置为cell
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//This is important, since we are inverting the tableview , all subview must be inverted as well
cell.transform = chatTableView.transform
return cell
}
但通过这种方式,您可以按最近的第一顺序加载单元格,确保所有子视图都使用与tableView 相同的转换