Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 518
O-mkar Avatar asked May 02 '16 07:05

O-mkar


People also ask

How do I change cell height in Swift?

To change the height of tableView cell in ios dynamically, i.e resizing the cell according to the content available, we'll need to make use of automatic dimension property. We'll see this with the help of an sample project.

How do you change the height of a tableView cell?

There are 2 steps to change height of a table cell without any additional code: Select your Table View from your Storyboard. In the Size Inspector change Row Height . Select your Table View Cell and while it's selected in the Size Inspector change the Row Height .

What is UITableView in Swift?

A view that presents data using rows in a single column. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.1+ tvOS 9.0+


1 Answers

You can adjust UITableView height and also manage reloading using below code

self.tableView.beginUpdates()

self.tableView.endUpdates()

enter image description here

like image 59
Sheereen S Avatar answered Sep 18 '22 18:09

Sheereen S