-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HeaderView Question #106
Comments
Override its -layoutSubview. Some may say that doing things in -scrollViewDidScroll: is fine, but it might give artifacts when swiped rapidly… so just subclass. :) On Jan 18, 2012, at 11:16 AM, BBuff wrote:
|
Thanks Monoceroi! That's where I started my search last night, but I can't tell for the life of me where the header view size is taken in to account in layoutSubviews. Any chance you can give me a nudge on this? Thanks again for taking the time to respond. I really appreciate it and the learning experience is great! |
Just take a look at the contentOffset, then you know where to move :) On Jan 18, 2012, at 19:42, BBuff
|
Thanks. I'll check this out tonight. Sent from my iPhone On Jan 18, 2012, at 7:49 AM, Evadne [email protected] wrote:
|
I played around with the contentOffset in layoutSubviews but then the searchbar was hidden but the ScrollView stopped scrolling. Any hints? |
Can you post the code? On Jan 21, 2012, at 5:32 AM, BBuff wrote:
|
The IF below is in layoutSubviews and I added the setContentOffset part. if ( _headerView != nil )
|
Not quite, but I digress. Realized that I might have misunderstood what you mean by “scroll down”. This should make your header view always appear:
If you want a header view that only appears when the user scrolls to the top, just adjust the You can also consider simply adding it above the zero point, then incrementing the content inset. But this is no much different than simply using the
|
Um, guess I am fabulously wrong. If the Grid View actually already makes sure that your header view is always at the top of the visible rect, then you move its
in your overridden |
So I just checked out the source and could verify that the gridHeaderView actually “sticks there”, meaning whenever the grid view is scrolled the header view scrolls with it. It strongly implies that the original implementation does what you wanted quite perfectly. Please post more code. If you can put the entire project up, better. |
Thanks for the follow-up. What I'm really looking for is for the headerView to be added to the top of the scrollView but I want the scroll to display starting at the bottom of the headerView. Then, when the user scrolls the view down with their finger the header view displays. The iBooks app, for example, does this. In the Library view you don't see the search bar initially but when you scroll the view down you do. Does that make sense? |
Doh. That means the header view is initially not shown, but pulling the entire list downwards reveals it. Usually, you can just use the
In other words, pre-scroll the entire grid view a bit so the header view is initially not shown. Guess this is what you’d like to do. |
When I add that to viewDidLoad the grid doesn't display any data. When I add it to viewWIllAppear it doesn't scroll. Here's what the grid view looks like in the immediate window. It looks like the contentOffset is getting set correctly. <AQGridView: 0xa18ba00; baseClass = UIScrollView; frame = (0 0; 320 416); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x9930100>; contentOffset: {0, 44}> |
I'm able to add a UISearchbar to the grid view's HeaderView and it displays properly. However, what I'd like to do is only show the header when the grid is scrolled down. This would allow access to the search bar without it being in the way all of the time. Does anyone have a recommendation on how to accomplish this?
Thanks in advance...
The text was updated successfully, but these errors were encountered: