大佬教程收集整理的这篇文章主要介绍了ios – 如何删除UITableViewCell滑动以删除弹跳,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
继续抵消的单元格:
即使拖动继续,我希望单元格停在此处:
我在我的cellForRowATindexPath:方法中尝试了这个,但似乎没有任何改变.
for(UIView *subview in cell.subviews){ if([subview isKindOfClass:[UIScrollView class]]){ UIScrollView *theScrollView = (UIScrollView *)subview; theScrollView.bounces = NO; } }
.H
@interface MyCustomcatell : UITableViewCell <UIScrollViewDelegate>
.M
-(void)awakeFromNib{ [super awakeFromNib]; for(UIView *subview in self.subviews){ if([subview isKindOfClass:[UIScrollView class]]){ UIScrollView *theScrollView = (UIScrollView *)subview; theScrollView.delegate = self; } } } #pragma mark - UIScrollViewDelegate -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ static CGFloat kTargetOffset = 82.0f; if(scrollView.contentOffset.x >= kTargetOffset){ scrollView.contentOffset = CGPointMake(kTargetOffset,0.0f); } }
这也可以在不使用自定义单元格的情况下完成,只需将ViewController设置为UIScrollViewDelegate并在tableView中设置UIScrollView的委托:cellForRowATindexPath,如下所示:
.H
@H_684_13@myViewController : UIViewController <UITableViewData@R_874_9016@e,UITableViewDelegate,UIScrollViewDelegate>
.M
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reusEIDentifier:cellIdentifier]; } for(UIView *subview in cell.subviews){ if([subview isKindOfClass:[UIScrollView class]]){ UIScrollView *theScrollView = (UIScrollView *)subview; theScrollView.delegate = self; } } return cell; } #pragma mark - UIScrollViewDelegate -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ static CGFloat kTargetOffset = 82.0f; if(scrollView.contentOffset.x >= kTargetOffset){ scrollView.contentOffset = CGPointMake(kTargetOffset,0.0f); } }
以上是大佬教程为你收集整理的ios – 如何删除UITableViewCell滑动以删除弹跳全部内容,希望文章能够帮你解决ios – 如何删除UITableViewCell滑动以删除弹跳所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。