上拉、下拉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.重新在另一个目录 ...
随机推荐
- hdu 2199
Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its sol ...
- win8 Pro 64位在 UEFI模式下Ghost系统 备份 恢复
一:在win8 安装U 盘中 1. 新建 “Ghost” 文件夹 2. 将下载的Ghost64.exe 文件拷贝到文件夹 二: 启动的时候 按下F12 选择 HDDUSB 1.Windows 安装 ...
- $.unique() 对象组成的数组去掉重复对象
发现一件事,一个完全由对象组成的数组,用$.unique()方法去掉重复的时候不管用 var arr = [{text:'第一个',value:'1'},{text:'第二个',value:'2'}, ...
- ecstore后台规格超过一定数量保存丢失
问题描述: 后台规格超过一定数量保存丢失,规格新增不了,删除出问题等不正常情况. 解决方法: 经过波波的不懈努力和日夜冥想终于破了.分析其原因就是因为多个规格组合生成的表单域太多,与php.ini配置 ...
- c语言中的结构体指针类型的cast
1.我们在c语言中会经常碰到强制类型转换. 在这,我介绍一种结构pointer类型转换,但是有前提(有点类似于c++中的继承中的子父对象的cast). 简单的介绍一下: 首先我们要知道一个结构的指针, ...
- 解决位于底端Edittext 输入时被软盘遮盖
遇到这种情况我们首先到网上搜一圈,大概情况是需要设置<activity/> android:windowSoftInputMode="adjustResize" ,按照 ...
- Tornado web 框架
Tornado web 框架 其实很简单.深度应用 一.简介 Tornado 是 FriendFeed 使用的可扩展的非阻塞式 web 服务器及其相关工具的开源版本.这个 Web 框架看起来有些像we ...
- sgu To xor or not to xor
题意:从n个数中,选择一些数,使得异或最大. #include <cstdio> #include <cstring> #include <algorithm> # ...
- DJANGO学习一则
这个WEB框架,可以好好研究,相信很快就会用在工作上的. 相关文件: settings.py """ Django settings for djangoweb proj ...
- nRF51822 SDK初体验
作为两家BLE芯片大厂之一,nordic不像TI那么开放,nordic的开发资料是很难找的. 今天有幸得到nordic的BLE芯片nRF51822的SDK,看了一下. 首先,nordic号称协议栈 ...