PushListView.h
@interface Pushlistview:uiview<uitableviewdelegate,uitableviewdatasource
{
CGFloat contentoffsety;
CGFloat oldcontentoffsety;
CGFloat newcontentoffsety;
}
pushlistview.m
Start dragging the view
-(void) scrollviewwillbegindragging: (Uiscrollview *) ScrollView{
Contentoffsety = Scrollview.contentoffset.y;
}
Call this method when scrolling (after the finger leaves the screen )
-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView{
//nslog (@ "scrollview.contentoffset:%f,%f", Scrollview.contentoffset.x, Scrollview.contentoffset.y);
Newcontentoffsety = Scrollview.contentoffset.y;
if (newcontentoffsety > Oldcontentoffsety && oldcontentoffsety > Contentoffsety) { // scroll up
NSLog (@ "up");
} Else if (Newcontentoffsety < oldcontentoffsety && Oldcontentoffsety < contentoffsety) {// scroll down
NSLog (@ "down");
} Else {
NSLog (@ "dragging");
}
if (scrollview.dragging) { // drag
NSLog (@ "scrollview.dragging");
NSLog (@ "contentoffsety:%f", contentoffsety);
NSLog (@ "newcontentoffsety:%f", scrollview.contentoffset.y);
if ((scrollview.contentoffset.y-contentoffsety) >5.0f) { // Pull up
// Hide navigation bar and options Bar
[Self layoutview];
[_viewcontroller.navigationcontroller Setnavigationbarhidden:yesanimated:YES];
[_viewcontroller.navigationcontroller Settoolbarhidden:!hidden Animated:yes];
_viewcontroller.tabbarcontroller.tabbar.hidden =YES;
} Elseif ((CONTENTOFFSETY-SCROLLVIEW.CONTENTOFFSET.Y) > 5.0f) { // drag down
// show navigation bar and options Bar
[Self layoutview];
[_viewcontroller.navigationcontroller Setnavigationbarhidden:noanimated:YES];
[_viewcontroller.navigationcontroller Settoolbarhidden:no Animated:yes];
_viewcontroller.tabbarcontroller.tabbar.hidden =NO;
} Else {
}
}
}
Complete the drag (call this method when scrolling stops, before the finger leaves the screen )
-(void) scrollviewdidenddragging: (Uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate{
NSLog (@ "scrollviewdidenddragging");
Oldcontentoffsety = Scrollview.contentoffset.y;
}
iOS determines the scrolling direction of the scrolling view