Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gopal.iosdev

macrumors newbie
Original poster
Jan 22, 2016
1
0
Hi,

My app has Expand or Collapse Functionaly, So to achieve that i have a table view with 7 Sections and each section has a header and footer with around 20 rows in each section, Initially I was only showing Headers of all the Sections by setting their height and hiding the footers and rows of section by setting the height 0 for footers and rows as You Can See in the Image 1 of the link i have attached, when the user clicks on + button of any header, i was reloading my tableview for that section and i was changing their heights to their actual height. During this process i have two issues



1.) Section Footers are overriding my table view cells when i was expanding sections before that, you can see this scenario in Image 2, 3, 4, 5. => i.e. Initially i expanded Section 1(i.e. Image 2) and then i expanded Section 0 (Image 3), when i scroll the rows in Section 0, I see section 1 footer over riding my sections 0 data cell(i.e. you can see in Image 4, 5).



2.) Expand or collapse animation is too fast => When i was trying to reload my table view for expand or collapse it is animating too fast.



any help is appreciated, i was finding hard time in solving it, you can find IMages URL, Git url for the code and table view reload code below.


Image Url:

Drop box link for all Images: https://www.dropbox.com/sh/3b0i57z74njckjr/AADv710M9ys7WUwkAB4dML4ya?dl=0


GitUrl for the project:


github.com/gopal-iosdev/ExpandOrCollapseTableView


tableVIew reload Code for Expand or collapse:



Code:
UITableViewRowAnimation rowAnimation = UITableViewRowAnimationBottom;

  NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:cellTag];

  NSRange range  = NSMakeRange(indexPath.section, 1);

  NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];

  [self.mainTableView beginUpdates];

  [self.mainTableView reloadSections:sectionToReload withRowAnimation:rowAnimation];

  [self.mainTableView endUpdates];


Thanks

Gopal
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.