一 先繼承 tableviewcell
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:申請(qǐng)域名、網(wǎng)絡(luò)空間、營(yíng)銷(xiāo)軟件、網(wǎng)站建設(shè)、樂(lè)平網(wǎng)站維護(hù)、網(wǎng)站推廣。
二添加左滑右滑
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];
三 實(shí)現(xiàn)左滑右滑功能
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];
}];
}
}
四添加左滑出來(lái)的視圖
-(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重用機(jī)制導(dǎo)致的問(wèn)題
- (void)prepareForReuse {
[super prepareForReuse];
[self reset];
}
demo 下載 http://download.csdn.net/detail/wjszf/7733277
分享標(biāo)題:IOSuitableviewcell左滑自定義
網(wǎng)站鏈接:http://muchs.cn/article40/pjjcho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、品牌網(wǎng)站設(shè)計(jì)、云服務(wù)器、網(wǎng)站策劃、外貿(mào)建站、定制開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)