且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

的UITableViewCell标签显示很少向上滑动动画

更新时间:2023-01-25 18:08:23

解决这个问题。很抱歉打扰你们。它是如此愚蠢的。我被刷新表时用户来自下一个视图控制器后通过调用REST API,然后调用 displayTable 的方法从底部显示的表。
现在,我称之为 reloadData ​​ code>方法来刷新它,如果它已经显示出来,而不是调用 displayTable

I am displaying list of persons in a tableView. On clicking any of the cell, app displays a new screen. When user comes back to previous screen, a tableView should appear. Here, when user comes back to screen with tableView, I call server API to get updated list of people and reload table to display them.

The issue is when user comes back to screen and tableView is displayed, label in UITableViewCell is animated a little bit. This animation is such that label moves from some place below its correct position and animation upwards to its correct position. This animation is not implemented by me, neither do I want it. Its visible for around 0.5-1 sec.

Compare below label's position before and after animation.

Has anyone experienced this?

Note : Note that I have used autolayout. Which might be an issue because before using autolayout this issue was not there.

Edit : Tried to disable implicit animation as shown below but not working.

NSMutableDictionary *newActions = [[NSMutableDictionary alloc] initWithObjectsAndKeys:[NSNull null], @"onOrderIn",
                                   [NSNull null], @"onOrderOut",
                                   [NSNull null], @"sublayers",
                                   [NSNull null], @"contents",
                                   [NSNull null], @"bounds",
                                   nil];
cell.textLabel.layer.actions = newActions;
cell.detailTextLabel.layer.actions = newActions;
cell.layer.actions = newActions;
cell.contentView.layer.actions = newActions;

Solved the issue. Sorry to bother you guys. It was so silly. I was refreshing the table when user comes back from next view controller by calling REST API and then calling a method displayTable which displays a table from bottom. Now, I call reloadData method to refresh it if its already displayed, instead of calling displayTable.