IOSuitableviewcell左滑自定义-创新互联
一 先继承 tableviewcell
成都创新互联是专业的城西网站建设公司,城西接单;提供成都网站设计、成都做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行城西网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!二添加左滑右滑
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
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站名称:IOSuitableviewcell左滑自定义-创新互联
URL分享:http://azwzsj.com/article/cdpdpj.html