ios - 防止在 iOS7 tableview 编辑模式下向左拖动单元格

标签 ios objective-c uitableview ios7

下面的屏幕截图显示了在行上向左滑动后处于编辑模式的一个表格 View 单元格。在编辑模式下,我可以按住单元格并再次向左拖动,这会显示这个空白区域(当我放手时有弹性效果)。我将每个单元格的背景图片设置如下:

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CellBG.jpg"]];

我有 2 个问题。

  1. 是否有可能阻止这种额外的拖动,从而永远不会看到这个白色区域?例如,想要与 iOS7 天气应用程序相同的行为。
  2. 另外,知道为什么删除按钮下方有细白线吗?

谢谢

Screenshot

最佳答案

  1. Is it possible to prevent this extra dragging so this white area will never be seen?

是的。将图像放在 UITableView 的背景上。不在手机上。因为如果你把图像背景放在一个单元格上,当你水平交换一个要删除的单元格时,那个单元格会移动。也就是说图像背景也会移动。但是如果你把它放在 UITableView 上,它就不会随 swap 移动。请记住将 UITableViewUITableViewCell 的背景颜色设置为清晰的颜色。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReuseIdentifier"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellBackground.png"]];
    imageView.frame = CGRectMake(0, kCellHeight*indexPath.row, 320, cell.frame.size.height);
    [tableView addSubview:imageView];
    [tableView sendSubviewToBack:imageView];
    return cell;
}

2.Also, any idea why there is thin white line under the delete button?

我认为这是 Apple 的小错误。您也可以在天气应用程序中找到它。所以别管那个。

关于ios - 防止在 iOS7 tableview 编辑模式下向左拖动单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18950629/

相关文章:

objective-c - 在初始化时将参数传递给自定义类

ios - 如何使用 GPUImage 检测文档的边缘

iPhone - TouchXML 是否使用未记录的 API?

iphone - UiView PopOut 的生涩动画

iphone - 使用registerNib :forCellReuseIdentifier,时,如何初始化UITableViewCell iVars?

ios - Xcode:在ARC中编译.c文件?

ios - 将 Javascript 注入(inject) Webview - Swift

ios - UITextField 没有成为第一响应者

uitableview - 横向调整内容 UITableviewcell

ios - 我可以在原型(prototype) UITableViewCell 中使用容器 View 吗