Search code examples
iosios6scroll

ios keep subview on top when scrolling


I have a UITableViewController. In the UITableView I have a subview - ImageView. ImageView this is my header of TableView. I want that header (ImageView) is always on top when I scroll.

I have the following code which work on IOS 5, but does not work on IOS 6:

- (Void) scrollViewDidScroll: (UIScrollView *) scrollView {
[ImageView setFrame: CGRectMake (0, self.tableView.contentOffset.y, 320, 100)];
}

So, what should I do to solve this problem on IOS 6?


Solution

  • The header and footer in UITableView and UICollection view are fixed inside there container scrollview. What you need to do is actually place a button outside of your UITableViewController and added after that controller either in Interface builder or when setting up your VC in viewDidload. This will then be above the scroll view. You might want to resize the UITableViewController so that the content doesnt pass under the button.