上拉、下拉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.重新在另一个目录 ...
随机推荐
- asp.net从服务器(指定文件夹)下载任意格式的文件到本地
一.我需要从服务器下载ppt文件到本地 protected void Btn_DownPPT_Click(object sender, EventArgs e) { ...
- Objective-C 字典、可变字典
字典相当于c++ stl中的map 字典NSDictionary #import <UIKit/UIKit.h> #import "AppDelegate.h" int ...
- Server.MapPath() 解析
Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径 ./当前目录 /网站主目录 ../上层目录 ~/网站虚拟目录 1.Server.MapPath("/&qu ...
- Linux 下源码安装JDK
一,找到.tar.gz源码包 将jdk1.XXXXXXX.tar.gz源码包放在你想方的位置,比如我就放到u盘的 1, mkdir /mnt/udisk ...
- window.onload,<body onload="function()">, document.onreadystatechange, httpRequest.onreadystatechang
部分内容参考:http://www.aspbc.com/tech/showtech.asp?id=1256 在开发的过程中,经常使用window.onload和body onload两种,很少使用do ...
- html5 百分比计算
这几天一直在看html5,看到了百分比的计算公式:目标元素的尺寸/上下文元素的尺寸=百分比尺寸.看到这个公式,有点懂,但是有不明白.对于目标元素很容易理解,但是对于上下文元素就不是很好理解了.试了一些 ...
- 根据文字计算Label的尺寸
CGSize size = [self.username.text boundingRectWithSize:(CGSize){130,20} options:NSStringDrawingUsesL ...
- (摘) MDI登陆问题
MDI编程中需要验证用户身份,那么登陆窗口就需要在验证密码后进行相关的隐藏处理. (1)隐藏登陆窗口(登陆窗体作为启动) 登陆按钮事件:this.Hide();//隐藏登陆窗口MDI_Name M = ...
- poj3261 -- Milk Patterns
Milk Patterns Time Limit: 5000MS ...
- VS2012 快捷键 VS Resharper 设置
原文 http://www.cnblogs.com/skyangell/archive/2013/03/24/2979835.html 一直用Resharper插件,最近发现Ctrl+E,C快捷见被R ...