0

我希望当用户滑动表格视图单元格时,显示多个编辑按钮(他默认是删除按钮)。是否可以在tableView:tableView editingStyleForRowAtIndexPath:方法中放置自定义按钮?

4

2 回答 2

0

我创建了一个新库来实现可滑动按钮,它支持各种转换和可扩展按钮,如 iOS 8 邮件应用程序。

https://github.com/MortimerGoro/MGSwipeTableCell

该库与创建 UITableViewCell 的所有不同方法兼容,并在 iOS 5、iOS 6、iOS 7 和 iOS 8 上进行了测试。

在此处输入图像描述

于 2014-08-10T21:10:37.397 回答
0

将手势识别器添加到您的类中,并在其选择器中尝试以下操作。

-(void)cellDidSwipeLeft:(UIGestureRecognizer *)_gestureRecognizer
{
     if(_gestureRecognizer.state == UIGestureRecognizerStateEnded)
     {
         CGPoint swipeLocation = [_gestureRecognizer locationInView:self.tableView];

            NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];


            UITableViewCell* swipedCell = (UITableViewCell *)[self.tableView cellForRowAtIndexPath:swipedIndexPath];
            YourCustomBtn *Btn = (YourCustomBtn *)[swipedCell viewWithTag:999];

            [self performAnimationOnObject:Btn forPoint:swipeLocation];
      }
}





-(void)performAnimationOnObject:(id)view forPoint:(CGPoint)point
    {
     CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
        animation.delegate = self;
        animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(btn.superview.frame.size.width, btn.center.y)];
                animation.toValue = [NSValue
                                     valueWithCGPoint:CGPointMake(mainCleanFrame.origin.x, btn.center.y)];
                animation.fillMode = kCAFillModeForwards;
                btn.center = CGPointMake(btn.frame.origin.x, btn.center.y);
    }
于 2012-12-21T11:11:37.360 回答