简体   繁体   中英

UITableView showing extra separator lines, on top of cells, when reloading page

I have a UITableView that contains mutiple sections. When my tab page first loads, everything looks fine. But when I navigate to a different tab, and come back, my UITableView has some extra separator lines.

I verified that numberOfRowsInSection is properly returning 2.

My row height is set to AutomaticDimension.

I am calling reloadData in viewDidAppear.

带有额外线条的 UITableView

I tried setting the background color of my table cells to white, but the extra lines are still visible.

The UITableView is inside of a UIScrollView, which I know is frowned upon, but I am doing the calculation to calculate the size of the TableView. Everything works perfectly on initial load, it's not until I return to the tab that I get the extra lines.

In my AccountViewController, I was calling an API to get the user's get account information in ViewDidAppear.

Instead of creating a new TableViewSource, I would clear out the existing data, and the repopulate it with the result of the API call. The flow was something like this.

  • Clear the Source Data
  • Call the API
  • Populate Source with API data
  • Reload Table Data

I ended up solving the problem by making a call to Reload Table Data after the source was cleared.

  • Clear the Source Data
  • Reload Table Data
  • Call the API
  • Populate Source with API data
  • Reload Table Data

Perhaps not the most efficient approach, but it was the easiest to implement within the current structure of the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM