ios - How to animate views according to tableview scrolling directions without content scrolling -
i'm trying implement specific tableview behaviour (like on facebook app).
i want have dynamic header magnified every time user scrolls , shrieked when user scroll down.
in addition want tableview cause effect of pushing header , scrolling tableview cells.
i used method:
- (void)scrollviewdidscroll:(uiscrollview *)ascrollview
in method calculated offset , direction , called method shrink or magnify header accordingly
so far good.
the thing animation being performed tableview scrolling.
to avoid it, created custom scrollview on of top of tableview, taged 2 scrollviews differently.
in scrollview created weak reference of tableview , boolean value indicated if scrollview should return tableview touch.
when shrinking\magnifying animation finished changed boolean value signal custom scrollview return tableview in hittest methods implemented inside scrollview.
but hittest not called when user keep scrolling (without leafing finger), in additions buttons inside tableviewcell aren't reacting.
here hittest method:
- (uiview*)hittest:(cgpoint)point withevent:(uievent *)event
{
uiview* result = [super hittest:point withevent:event]; if (_recievetouchontable) { return _table; } else return result;
}
here scrollviewdidscroll method: (onprogress means animation being performed, keep returning custom scrollview) tag = 2 = custom scrollview tag = 1 = tableview
- (void)scrollviewdidscroll:(uiscrollview *)ascrollview { cgfloat yvelocity = [ascrollview.pangesturerecognizer velocityinview:ascrollview].y; cgfloat offset = lastcustomscrollviewcontentoffset.y-ascrollview.contentoffset.y; lastcustomscrollviewcontentoffset =ascrollview.contentoffset; if (yvelocity<0) offset = fabs(offset)*-1; else if(yvelocity>0) offset = fabs(offset); if (offset!=0 && ascrollview.tag == 2) [self layoutviewaccorrdingtotableviewscorlingvelocity:offset]; if (!onprogress ){ customscrollview.recievetouchontable=yes; }
}
am missing something, or maybe there's more simple way it?
Comments
Post a Comment