Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

ios - How to increase the single row height without reloading UITableView or individual cells [Swift]?

I want to expand the row height and show the content inside. I show my content in view I want when I tap on a cell it should expand like showed in the image below but without reloading the UITableView.

image

What I have tried till now

  1. I tried expanding the view inside but it didn't work

  2. I tried adding rowAtIndex it was becoming complicated

  3. I tried changing change row height and scroll at index it worked fine but I don't want like that. (bad thing I have to reload the table view)

But I got many answers but it didn't address my issue as my data in the array(data source) is continuously updated if I refresh at specific index the data in the array at the index might be different it might show the wrong output.

Explanation

I mean I have an array of struct I keep on updating it in background once the data change and reload the table view but if the i reload the row at index and if the data in an array is already changed it might show duplication correct? so i want to just change the height of the row without doing any reload.

Problem with reloading is

while expanding the data might change in the array. so i already created a view and all the info is preloaded once i tap the height of the cell should change from 45 to 76 and once i tap different cell again from last cell 76 to 45 and this cell 45 to 76.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You don't even need to reload the cell, just get the current cell at the target location and modify it directly and call beginUpdates and endUpdates on the table view to have it recalculate all of the row heights.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...