iosobjective-cxcode10.1

The table-view moving up and down like jumping continuously


I am working in a project which is in Objective C and Xcode version is 10.1. In this project I am using socket. In this app I am continuously reading data from Socket. And I am showing the updated value into table view. For that I am reloading the table section header as fast as data comes from socket. Means If I get id = 5 then I try to find index of section whose id == 5 and I will update that section only.

Now the problem is when I tap on table header it opens inner row of that section header and after that when I scroll down, the table-view moving up and down like jumping continuously because data is coming in such a fast way.

For Ex. : Table View

Case 1 :(Scroll is working perfectly)

Case 2 : (Scroll will lead to Jumping Headers)

So in above structure, when we click on Header 1 and then we scroll down, at that time next headers are jumping because of continuous update process.

This jumping header effect in scroll, is not coming in Case 1 scenario. This happened only in Case 2.

This problem was not occurring when I was reloading the whole table instead of reloading the only one section header at a time. Please help me in this issue. Thanking you in advance.

I tried to reload section header like mentioned in below. [tableView beginUpdates]; [tableView reloadSections:[NSIndexSet indexSetWithIndex:i] withRowAnimation:UITableViewRowAnimationNone]; [tableView endUpdates];


Solution

  • If you are using "heightForRowAtIndexPath:" method to calculate the height. Use "estimatedHeightForRowAtIndexPath" this method also. Write code in row height method.