-1

I have UITableView with static cells (just 2).

In first static cell i am adding UIView as a cell Subview

For the second static cell i am adding UICollectionView also as a cell Subview

(as you can see on attached image)

So, what i am trying to achieve is when UICollectionView is populated with content the primary scroll to the view to be UITableView itself.

This is possible if we disable UICollectionView scrolling.

But exactly here is the problem:

To make everything to work properly i need to know UICollectionView height and to add it as cell height. But in my case i don't know this because i am adding more content to UICollectionView dynamically.

Maybe the real question is: Is it possible to update cell height after cell initializing?

P.S. I prefer this kind of structure instead of using UICollectionViewHeader because i want to change UICollectionView completely based on user interaction.

As shown here

Any ideas and directions are hardly appreciated.

Thanks in advance.

Oleg Popov
  • 2,464
  • 1
  • 17
  • 15

1 Answers1

0

You can manually calculate the height of the UICollectionView based on your data source. Then return that from (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath method. Then reload your table when your Collection View data source changes.

This might be helpful.

Community
  • 1
  • 1
Ishan Handa
  • 2,271
  • 20
  • 25