189 8069 5689

IOSuitableviewcell左滑自定义

一 先继承 tableviewcell

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:申请域名、网络空间、营销软件、网站建设、乐平网站维护、网站推广。

二添加左滑右滑

    UISwipeGestureRecognizer *swipeLeft=[[UISwipeGestureRecognizer alloc] initWithTarget:selfaction:@selector(swipeCell:)];

    swipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;

    [self addGestureRecognizer:swipeLeft];

    

    UISwipeGestureRecognizer *swipeRight=[[UISwipeGestureRecognizer alloc] initWithTarget:selfaction:@selector(swipeCell:)];

    swipeRight.direction=UISwipeGestureRecognizerDirectionRight;

    [self addGestureRecognizer:swipeRight];

三 实现左滑右滑功能

if (swipe.direction==UISwipeGestureRecognizerDirectionLeft) {

      __block CGPoint point=self.contentView.center;

        if (point.x>=(self.frame.size.width-self.swiftLeftLength)) {

            [self stepLeftView];

            [UIView animateWithDuration:0.15 animations:^{

                

                point.x=point.x-self.swiftLeftLength;

                self.contentView.center=point;

                

                UIView *leftView=[self viewWithTag:505];

                CGRect frame=leftView.frame;

                frame.origin.x=self.frame.size.width-self.swiftLeftLength;

                leftView.frame=frame;

            } completion:^(BOOL finished) {

                

            }];

            

            

        }

  

    }else if (swipe.direction==UISwipeGestureRecognizerDirectionRight){

      __block  CGPoint point=self.contentView.center;

        if (point.x<(self.frame.size.width-self.swiftLeftLength)) {

            

            [UIView animateWithDuration:0.15  animations:^{

                point.x=point.x+self.swiftLeftLength;

                self.contentView.center=point;

                

                UIView *leftView=[self viewWithTag:505];

                CGRect frame=leftView.frame;

                frame.origin.x=self.frame.size.width;

                leftView.frame=frame;

                

            } completion:^(BOOL finished) {

                

                [self removeLeftView];

                

            }]; 

        } 

    }

四添加左滑出来的视图

-(void)stepLeftView{

    UIView *leftView=[[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width, 0, self.swiftLeftLength,self.frame.size.height)];

    leftView.tag=505;

    [leftView addSubview:self.leftContentView];

    [self addSubview:leftView];

}

五 解决cell重用机制导致的问题

- (void)prepareForReuse {

    [super prepareForReuse];

    [self reset];

}

demo 下载 http://download.csdn.net/detail/wjszf/7733277

IOS uitableviewcell 左滑 自定义


分享题目:IOSuitableviewcell左滑自定义
文章链接:http://cdxtjz.cn/article/pjjcho.html

其他资讯