0

I have a gridview which I am using, it has a header, side bar and then the gridview inside, I have setup scrolling but it's not working like the way I want it.

I'm trying to make the scrolling so that when I scroll horizontally my left side bar will stay while the grid only scrolls but when I scroll vertically I want it to move with the grid. And I wanted my header at the top to do the same, so vertically scrolling will make it stay and horizontally scroll will make it move with the grid.

I have done a scroll view but it all moves together and doesn't work right.

so can someone please help me, thanks.

Nishant Tyagi
  • 9,893
  • 3
  • 40
  • 61
shamal
  • 25
  • 6
  • 1
    can u show some sample screenshots what u r trying to make.. and let us know d code implemented so far.. – vishy Apr 25 '13 at 09:07
  • i will add it now..thanks – shamal Apr 25 '13 at 09:25
  • here is a example of what i'm trying to make: http://a603.phobos.apple.com/us/r1000/077/Purple/v4/87/df/c2/87dfc2f5-99d3-c8fc-5e08-60b3f677e2ec/mzl.kvwmkpcc.320x480-75.jpg – shamal Apr 25 '13 at 09:28
  • check this one http://stackoverflow.com/questions/2543670/ios-finding-the-direction-of-scrolling-in-a-uiscrollview – Balu Apr 25 '13 at 09:31
  • so in the example: the logos on the side is my side bar, at the top the timings are my header and then the gridview.. – shamal Apr 25 '13 at 09:31

2 Answers2

0

The best way to do so, is to move the inside views of the scollview in the opposite direction of the scrollview for example you have the UIView called "Bar" in your scrollview, you need to detect every time the scollview scolls by its delegate and move the "Bar" with it:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
   // Move is horizontal
   if (self.lastContentOffsetX != scrollView.contentOffset.x)
   {
      [Bar setFrame:CGRectMake(scrollView.contentOffset.x,Bar.frame.origin.y, Bar.frame.size.width, Bar.frame.size.height)];
   }
   // Move is vertical
   if (self.lastContentOffsetY != scrollView.contentOffset.y)
   {
     //Move another control that you want to be steady 
   }
   self.lastContentOffsetX = scrollView.contentOffset.x;
   self.lastContentOffsetY = scrollView.contentOffset.y;

}

0

Use [scroll_View setPagingEnabled:YES]; this will work

Divyam shukla
  • 2,038
  • 14
  • 18