문제

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);
        }
    }
도움이 되었습니까?

해결책

  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.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top