【问题标题】:How to add panMovement to UITableView Cell如何将 panMovement 添加到 UITableView 单元格
【发布时间】:2014-06-16 14:39:19
【问题描述】:

我有一个来自 NIB 的表格和自定义单元格。基本上我需要的是将自定义单元格从表格滑到右侧。它必须是光滑的,并且桌子本身不应该塌陷。 (操作完成后,单元格将返回)。我有一些部分,1 行/部分,所以基本上我需要随着部分移动。非常感谢您的回答!

我的 cell.m 文件如下所示:

#import "MIKETableViewCell.h"

static NSString *CellTableIdentifier = @"MIKETableViewCell";

@implementation MIKETableViewCell

@synthesize timeLabel = _timeLabel;
@synthesize priceLabel = _priceLabel;
@synthesize infoLabel = _infoLabel;


- (void)awakeFromNib
{
    // Initialization code
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:CellTableIdentifier];

return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

// Configure the view for the selected state
}


@end

【问题讨论】:

  • 您是否已经尝试过任何方法来实现这一目标?
  • 我试图将 IB 中的 panMovement 动作放到单元格中。与我对 ViewControllers 中的视图所做的相同,但这不起作用,我尝试了教程中的其他一些解决方案,但对我没有任何效果:/ 我确定我缺少一些基本的...

标签: ios iphone objective-c cocoa-touch uitableview


【解决方案1】:

添加这个:

 -(void)layoutSubviews
 {
     UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tableCellClicked)];
    tapGesture.numberOfTapsRequired = 1;
    [self addGestureRecognizer:tapGesture];
 }

【讨论】:

  • 您能说得更具体些吗?你能在我的代码中显示它吗?非常感谢
  • 您的代码中是否调用了 -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier?
  • 知道了。为您编辑答案
  • 在单元格上平移时启动该操作,但单元格没有移动。我添加了与其他视图中的子视图相同的移动方法(代码),它工作正常......也许在 tableView 中的不同方法?无论如何,这回答了我的问题如何启动行动,谢谢;)
  • 用你的代码添加另一个问题,我会尽力帮助欢呼!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-17
  • 2015-04-10
  • 2011-10-17
  • 1970-01-01
  • 1970-01-01
  • 2014-01-24
  • 2011-12-22
相关资源
最近更新 更多