Reputation: 3376
I'm using plain-style UITableView
with sections, which have sectionView's. So, i will put UISearchBar
as table-header-view and i need it was always visible on the top, but keep scrollable behaviour when user scroll down.
There's a picture how it looks like
So, i need to show HeaderView
between navigation bar and section 2..3..N when scroll. Header view should stick to navigation bar, and section header view should stick to the header view.
I tried next methods:
@implementation MyTableViewController
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGRect rect = self.tableHeaderView.frame;
rect.origin.y = MIN(0, self.tableView.contentOffset.y);
self.tableHeaderView.frame = rect;
}
and
@implementation MyTableView
-(void)layoutSubviews
{
[super layoutSubviews];
CGRect rect = self.tableHeaderView.frame;
rect.origin.y = MIN(0, self.contentOffset.y);
self.tableHeaderView.frame = rect;
}
But get no results.
Upvotes: 2
Views: 685
Reputation: 63
You,Maby don't use UIScrollViewDelegate
scrollView.delegate = self
and if you want use scrollView In StoryBoard - connect it there,
you could fully show your code in the class UITableView
?
and use ViewDidLoad
!!!
Upvotes: 1