上拉、下拉UITableView,交互式 模态弹出(自定义弹出动画)

部分代码 InteractiveTransition 类继承NSObject:
- (instancetype)initWithPresentingController:(UITableViewController *)presentingVc presentedController:(UIViewController *)presentedVc {
self = [super init];
if (self) {
self.vc = presentedVc;
self.vc.transitioningDelegate =self;
self.presentingVc = presentingVc;
}
return self;
}
- (void)new_scrollViewWillBeginDragging:(UIScrollView *)scrollView {
self.interactiveTransition = [[UIPercentDrivenInteractiveTransition alloc]init];
[self.presentingVc presentViewController:self.vc animated:YES completion:nil];
}
- (void)new_scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offsetY = fabs(scrollView.contentOffset.y);
CGFloat screenH = [UIScreen mainScreen].bounds.size.height / 3.0;
progress = offsetY / screenH;
progress = progress-0.3;
if (progress > ) {
[self.interactiveTransition updateInteractiveTransition:progress];
}
}
- (void)new_scrollViewWillEndDragging {
if (progress < 0.4) {
[self.interactiveTransition cancelInteractiveTransition];
}else {
[self.interactiveTransition finishInteractiveTransition];
}
self.interactiveTransition = nil;
}
- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
return self.animation;
}
- (id<UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id<UIViewControllerAnimatedTransitioning>)animator {
return self.interactiveTransition;
}
PresentAnimation 类继承NSObject 实现 UIViewControllerAnimatedTransitioning协议
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
return 1.0;
}
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
UIView *containerView = [transitionContext containerView];
[containerView addSubview:toView];
toView.frame = CGRectMake(, containerView.bounds.size.height, containerView.bounds.size.width - , containerView.bounds.size.height - );
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toView.frame = containerView.bounds;
}completion:^(BOOL finished) {
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}
控制器:
- (InteractiveTransition *)interactive {
if (!_interactive) {
_interactive = [[InteractiveTransition alloc]initWithPresentingController:self presentedController:[[TwoViewController alloc]init]];
}
return _interactive;
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.interactive new_scrollViewWillBeginDragging:scrollView];
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
[self.interactive new_scrollViewWillEndDragging];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self.interactive new_scrollViewDidScroll:scrollView];
}
完整代码:http://pan.baidu.com/s/1i3Uewip
上拉、下拉UITableView,交互式 模态弹出(自定义弹出动画)的更多相关文章
- [BS-23] AFN网络请求上拉/下拉刷新的细节问题总结
上拉/下拉刷新的细节问题总结 1.如果导航栏有透明色,则也需要设置header自动改变透明度 self.tableView.mj_header.automaticallyChangeAlpha = Y ...
- Swiper 判断上滑下拉操作
onTouchMove: function(swiper){ //手动滑动中触发//判断上滑下拉var i = mySwiper.translate;setTimeout(function() {va ...
- ios position:fixed 上滑下拉抖动
ios position:fixed 上滑下拉抖动 最近呢遇到一个ios的兼容问题,界面是需要一个头底部的固定的效果,用的position:fixed定位布局,写完测试发现安卓手机正常的,按时ios上 ...
- 浅谈对MJRefresh(上)下拉刷新控件的理解
MJRefresh GitHub地址:https://github.com/CoderMJLee/MJRefresh 利用业余时间研究了一下iOS的开发,发现OC特定的语法方式吸引了我,而且iOS开发 ...
- jsp页面上的下拉框案例(Struts2)
<s:select></s:select>包含的属性有:list="" :name="" :value="" ...
- 160823、ionic上拉/下拉更新数据
<!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF- ...
- js实现页面的上滑下拉功能
这两天做项目,用到了上滑和下拉的功能,主要是通过监听touchmove,touchstart,touchend三个事件去判断页面上滑状态还是下拉状态. 同时加一个知识点:有时在监听时会报错,这个错是这 ...
- SDI在自定义的工具栏上添加下拉控件
0.首先到自己的工具条上新建一个控件,并命名新ID 1.拷贝FlatComboBox.h和FlatComboBox.cpp到工程目录下 2.建立新类 class CTrackerToolBar : p ...
- 小程序 上啦下拉刷新window配置
"enablePullDownRefresh": "true" /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefres ...
- git过期后,如何将新建的项目push到码云上而且下拉成功
1.在码云上创建一个项目: 2.打开STS(spring Tool Suite) 新建一个Maven(webapp)项目: 3.打开你的码云账号,把码云上的工程的URL复制: 4.重新在另一个目录 ...
随机推荐
- Cocos2d-x 3.x部署到安卓
一.前期准备 下载下列软件: Python2.7 (https://www.python.org/downloads/) Cocos2d-x 3.x (http://www.cocos2d-x.org ...
- JS常用的方法
1.时间戳转换 //时间戳(有Date和无Date的都可)转换为日期 “2016年5月30日 10:29:30 2016-05-20 09:11” function TimeConversion(ti ...
- 【Nutch2.2.1基础教程之6】Nutch2.2.1抓取流程
一.抓取流程概述 1.nutch抓取流程 当使用crawl命令进行抓取任务时,其基本流程步骤如下: (1)InjectorJob 开始第一个迭代 (2)GeneratorJob (3)FetcherJ ...
- project euler 14 collatz
def collatz(num,i): i =i + 1 if num%2 == 0: return collatz(num//2,i) elif num == 1: return i else: r ...
- Loadrunner根据PV量来确定需要进行压测的并发量
在实际做压力测试的过程中,我们有时不知道用怎样的并发量比较好,下面是几个用PV量去确定并发量的公式,这个在我们公司是比较适用的,大家可以根据自己的业务进行运算. 方法一:这个方法是我在网上查到的80- ...
- Android开源库
http://blog.csdn.net/xiaanming/article/details/9470223 一.兼容类库 ActionBarSherlock : Action Bar是Android ...
- Codeforces 414B Mashmokh and ACM
http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...
- ImageMaigck不支持中文路径的问题
不知道咋回事. 回顾下: char* pTest1 = "测试.txt"; wchar_t* pTest2 = L"测试.txt"; 以上是pTest1指向的内 ...
- NOI2012 Day1
NOI2012 Day1 随机数生成器 题目描述:给出数列\(X_{n+1}=(aX_n+c)mod m\),求\(X_n mod g\) solution: 矩阵乘法,但数有可能在运算时爆\(lon ...
- 福建省队集训被虐记——DAY3
昨天没写--今天补上吧 一如既往的跪了 棋盘 [问题描述] 给出一个N*M的方格棋盘,每个格子里有一盏灯和一个开关,开始的时候,所有的灯都是关着的.用(x, y)表示第x行,y列的格子.(x, y)的 ...