Created
May 17, 2013 21:21
-
-
Save kenshin03/5602049 to your computer and use it in GitHub Desktop.
pull to dismiss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - UITableViewDelegate delegate | |
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
if (scrollView.contentOffset.y < -160.0f){ | |
dispatch_once(&pullToDismissLock, ^{ | |
CGRect destFrame = self.notificationsTableView.frame; | |
destFrame.origin.y = destFrame.size.height; | |
[UIView animateWithDuration:0.4f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{ | |
self.notificationsTableView.frame = destFrame; | |
self.notificationsTableView.alpha = 0.0f; | |
} completion:^(BOOL finished) { | |
if ([self.delegate respondsToSelector:@selector(notificationsViewController:shouldDismissView:)]){ | |
[self.delegate notificationsViewController:self shouldDismissView:YES]; | |
} | |
}]; | |
double delayInSeconds = 1.2; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
pullToDismissLock = 0; | |
}); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment