Question

In my iphone app

i need to display header for the first section of the table view...

My requirement is to stick the header at the top of the table view (ie fixed at the bottom of the navigation bar) while scrolls down and

header Moves top top with scrolling while scroll to top side

just like face book page how the Post, Photo cheack-in location are below the Navgation bar. And when the user starts browsing the wall to top, this disappears... and pulling down it sticks at same place

I have tried with following code

it works for scroll to top

not working for scroll to down.

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat sectionHeaderHeight = 50;
        if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0)
        {
            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
        } else if (scrollView.contentOffset.y>=sectionHeaderHeight)
        {
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
        }
    }
Was it helpful?

Solution

  1. It's not possible to get that effect as smooth as you want using the header view.
  2. Better way to achieve this is using the two different control.
  3. Have your table view as a separate control and use another control to create the header.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top