title: App Store app view layout
body: <p>I would like to create a view similar to the App Store's app view on the iPhone :</p>
  
  <p><a href="http://cl.ly/image/0Q1h273v3C00" rel="nofollow">http://cl.ly/image/0Q1h273v3C00</a></p>
  
  <p>Basically when you scroll down, part of the header remains fixed at the top :</p>
  
  <p><a href="http://cl.ly/image/3m0I3Y0t1901" rel="nofollow">http://cl.ly/image/3m0I3Y0t1901</a></p>
  
  <p>Here's the approach I tried, but it doesn't work as expected :</p>
  
  <ul>
  <li>I use a tableView as the 'global view'</li>
  <li>In this example, my tableView header would be the top part with the app icon, name ... and UISegmentedControl</li>
  <li>Below the header is my regular tableView with cells...</li>
  <li><p>Then, I simply implement the method below :</p>
  
  <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView
  {
      // Keeping the menu always visible when user scrolls
      // 155 is the original y position of the menu (UISegmentedControl here)
      if (scrollView.contentOffset.y &gt; 155) {
          self.menuView.frame = CGRectMake(0,
                                           scrollView.contentOffset.y,
                                           self.menuView.frame.size.width,
                                           self.menuView.frame.size.height);
      }
      else {
          self.menuView.frame = CGRectMake(0,
                                           155,
                                           self.menuView.frame.size.width,
                                           self.menuView.frame.size.height);
      }
  }
  </code></pre></li>
  </ul>
  
  <p>The menu remains at the top position just as I want, but still it's not working as expected :</p>
  
  <ul>
  <li><p>My tableView section headers overlap the menu when I scroll. The only fix I found is to put the header layer at the top using this code :</p>
  
  <pre><code>self.tableView.tableHeaderView.layer.zPosition = MAXFLOAT;
  </code></pre>
  
  <p>But now the scrollbar is hidden behind the header, so I'm not satisfied with this either
  I also tried to use this call in viewDidLoad and ...viewForHeaderInSection</p>
  
  <pre><code>[self.tableView bringSubviewToFront:self.tableView.tableHeaderView];
  </code></pre>
  
  <p>but it just doesn't work, since the section headers are always added after the tableView header and I haven't found a way to know when the section headers are added, so I can put them behind the tableView header.</p></li>
  <li>When I scroll down more than the menu's initial position, even though the menu remains fixed at the top, I can't click on it, all the events are going to the tableviewcell behind it.</li>
  <li>Finally, I want to be able to keep the same header when I click on the other buttons of the UISegmentedControl, just like in the App Store app view, and just change the content below, but I don't want to include the same header each time in each of my views, I would like to make the header generic.</li>
  </ul>
  
  <p>Does anyone have any ideas on how to tackle the problems I'm facing, or a different approach to this ?</p>
  
  <p>P.S : Youtube does kinda the same thing for the channel view, but their solution is not as good as Apple's, as you can't move the content if you start scrolling from the header.</p>
  
  <p>Thanks for your help!</p>