0

I have a dynamic UITableViewCell. Now my problem is in some cases I wanted to have the cell to be fixed, the cell should be in top position, while other cells keeps scrolling under it.

Normal table view

This UITableView is normal case, every cell should be scrollable here.

But,

Table View which first cell should be fixed in the position

In this UITableView, the first cell should be fixed.

PS. the cell which will going to be fixed is always present at the top of the UITableView.

I did tried with the viewForHeaderInSection:, But that did not worked for me, as the cell is generated dynamically and each cell again have a collectionView in them, which will provide data form strength and price.

I also tried scrollViewDidScroll and the cell is fixed, but get replaced by the next cell as soon as it get's disappear. For scrollViewDidScroll I looked and try to implement as suggested in this thread: UITableView - How to keep table rows fixed as user scrolls

Gaurav Patel
  • 532
  • 1
  • 5
  • 19
Asis
  • 683
  • 3
  • 23
  • 1
    Problem in your code not in ui just share your tableview code. –  Apr 23 '18 at 04:56
  • @RB1509 I am searching for the way to implement it, As I have no idea how to do that. So, I am sharing my scenario. – Asis Apr 23 '18 at 05:00

2 Answers2

1

You can make a custom cell as your header section

For example:

- (UIView )tableView:(UITableView )tableView viewForHeaderInSection:(NSInteger)section {
     customHeaderSection *headerCell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"];

     return commentCell;
}
tedd
  • 65
  • 7
0

If you want to create a custom header, implement the tableView:viewForHeaderInSection: method in your table view delegate and return the view for your header.You will have to manage sections and rows instead of just rows.

Rashed
  • 2,349
  • 11
  • 26
  • Yea I got that, but Can I generate a header in section, which will have exact properties of the cell ? As it also needs to have a collection view within itself. – Asis Apr 23 '18 at 05:02
  • 1
    https://stackoverflow.com/questions/31693901/design-uitableviews-section-header-in-interface-builder – Rashed Apr 23 '18 at 05:04