一 先继承 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
分享标题:IOSuitableviewcell左滑自定义
网站链接:https://www.cdcxhl.com/article40/pjjcho.html
成都网站建设公司_创新互联,为您提供网站改版、品牌网站设计、云服务器、网站策划、外贸建站、定制开发
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联