0

I have a tableview with custom-designed cells and thus if I add the swipe-to-delete buttons the layout is horrible. Is it possible to reposition these buttons inside the cell?

4

3 回答 3

1

你不应该这样尝试,你不应该改变 Apple 的默认视图。

于 2013-07-31T12:21:19.300 回答
0

不,无法使用删除按钮进行任何更改,因为它是 Apple iOS 的内置或默认功能。所以最好停止与之斗争:)

于 2013-07-31T12:20:07.277 回答
0

是的,您可以更改按钮。

也许这段代码可以帮助你。在 yourCustomCell.m 中编写以下代码

- (void)willTransitionToState:(UITableViewCellStateMask)state 
  {
      [super willTransitionToState:state];
      if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) 
      {
          for (UIView *subview in self.subviews) 
          {
              if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) 
              {
                  UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
                  [deleteBtn setImage:[UIImage imageNamed:<yourCustomImage.png>]];
                  [[subview.subviews objectAtIndex:0] addSubview: deleteBtn];
          }
       }
    }
 }

可以设置框架UIImageView

于 2013-07-31T12:21:13.623 回答