上拉、下拉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 > 0) {
        [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(50, containerView.bounds.size.height, containerView.bounds.size.width - 100, containerView.bounds.size.height - 300);

    [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

时间: 2024-09-29 21:54:43

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

[BS-23] AFN网络请求上拉/下拉刷新的细节问题总结

上拉/下拉刷新的细节问题总结 1.如果导航栏有透明色,则也需要设置header自动改变透明度 self.tableView.mj_header.automaticallyChangeAlpha = YES; //允许自动改变透明度 2. 下拉刷新必须手动调用[self.tableView.mj_header beginRefreshing];才开始刷新,下拉刷新只要用户滚动到最下方,自动开始加载更多. 3. 上拉刷新通常用的是用MJRefreshAutoNormalFooter,该控件总是紧贴最

Android PullToRefresh上、下拉刷新

支持各种上.下拉刷新. Github: https://github.com/chrisbanes/Android-PullToRefresh Features Supports both Pulling Down from the top, and Pulling Up from the bottom (or even both). Animated Scrolling for all devices. Over Scroll supports for devices on Android v

TableView上的下拉刷新及抓获本地时间。

#import <UIKit/UIKit.h> @interface ViewController : UITableViewController{        NSMutableArray *timeArray;        UIRefreshControl *refresh;    } @property (strong,nonatomic)NSMutableArray *timeArray;@property (strong,nonatomic)UIRefreshControl *r

浅谈对MJRefresh(上)下拉刷新控件的理解

MJRefresh GitHub地址:https://github.com/CoderMJLee/MJRefresh 利用业余时间研究了一下iOS的开发,发现OC特定的语法方式吸引了我,而且iOS开发中有很多有趣的东西,正是如此,重新激起了我对开发学习的兴趣.自学过程中,知道了这个MJRefresh,MJ真乃大神也. 废话不多说,MJRefresh集成了UIView,UICollectionView,UITableView的上下拉刷新功能,而且还有自定义文字,动画等功能.针对GitHub上的源代

上、下拉电阻

单片机上拉电阻作用 加上拉电阻或下拉电阻就是从电源V+或V-端到集成电路器件输出端加装一个电阻,即直接在器件的输出脚到电源V+或V-端焊接一个电阻即可.1.上拉电阻对器件注入电流,常见的加装目的有两个:(1)提高输出电平.如TTL输出驱动COM的电平匹配,这是非常必要的.(2)加大输出驱动能力,但对于非OC或OD输出型电路其作用是有限的,如果用于驱动类似LED不加上拉或下拉电阻也是可以的,应该从负载限流电阻等方面考虑解决,如果负载比较重,应该加装输出缓冲或功率驱动电路.对于OC或OD电路,必须由

160823、ionic上拉/下拉更新数据

<!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF-8"> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width,height=device-height"

PullToRefreshView 上啦下拉刷新

public class PullToRefreshView extends LinearLayout { // private static final String TAG = "PullToRefreshView"; // refresh states private static final int PULL_TO_REFRESH = 2; private static final int RELEASE_TO_REFRESH = 3; private static final

c# - Winform DatagridView上显示下拉树

Winform的DatagridView是不支持下拉树的,所以需要扩展 废话不多说,直接贴代码 首先需要对comBox扩展,下拉内容变成TreeView using System.Drawing;using System.Windows.Forms;namespace WindowsApplication23{ public class ComboBoxTreeView : ComboBox { private const int WM_LBUTTONDOWN = 0x201, WM_LBUTT

翻翻git之---RecycleView的上拉,下拉刷新,样式切换,添加foot和header的强大库 RecyclerViewManager

转载请注明出处王亟亟的大牛之路 前两天写了一个上拉刷新的,今天看到个上下拉都可刷新还实现了foot 和header以及3种RecycleView样式的切换就给大家介绍下,先贴下foot部分因为实例中并没加入foot 这部图片大小 没搞好 再贴一下2个刷新的效果 因为作者是中国人,所以实现原理他写了一个很好的解释文章,这边就不罗嗦了看传送门:http://z.sye.space/2015/11/23/RecyclerViewManager/ how to use? Grade: allprojec

关于上拉/下拉刷新的一些认识

uiTableView继承自uiScrollView所以此方法对uiTableView同样有效,测试发现:在uiTableView的偏移量中, scrollView.contentOffset.y是由ScrollView内容视图的高度与UITableView的高度比较而来的,视图向下移动偏移量增加,向上则减少,这样若果是最后一行,ScrollView内容的高度必定会小于,偏移量加上UITableView的高度,向上直接判断是否为负数即可.