Reputation: 117
I'm looking to have a semi-sticky tableViewHeader
just like the iOS7 app store detail view. The detail view is the screen with the Details | Reviews | Related UISegementedControl
where you actually download the app. Unfortunately, I don't have enough reputation to post images, but it starts off normally at the top. As you scroll up, it scrolls normally as well. However, once the UISegementedControl
hits the top, it sticks. I am going to have multiple sections in the table.
I've gotten this to work correctly visually using auto layout by adding the top view as the tableHeaderView and intercepting the scrollViewDidScroll event:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y > 69) //offset from top to uisegmentedcontrol
self.toolBarHeightToTop.constant = scrollView.contentOffset.y; //toolBarHeightToTop is auto layout constraint from uisegmentedcontrol to top of header
else
self.toolBarHeightToTop.constant = 69; //default
}
However, the UISegmentedControl
does not detect touch events. Instead, the UITableView
delegate method tableView:didSelectRowAtIndexPath:
is raised. Any ideas?
Upvotes: 1
Views: 2224
Reputation: 55623
Both the header and the segmented control are UITableView
Header's and the content below the segmented control belongs in a UITableViewCell
The header (above the UISegmentedControl
) is in a UITableView
section that doesn't have any rows (but it does have a header).
The UISegmentedControl
is the header of a UITableView
section that has 1 row - the content that you see and a header - the UISegmentedControl
Upvotes: 3