【发布时间】:2014-06-16 18:31:01
【问题描述】:
我有一个表格,其中包含来自 NIB 文件的自定义单元格。结果应该看起来像,我要抓住单元格并将其滑出屏幕。注意:只是单元格的一部分。其他部分会留下来。我在单元格上运行 pan Movement 时遇到问题。 NSlog 记录了正确的移动,但我无法与单元格一起移动。我的 cell.m 看起来像这样:
#import "MIKETableViewCell.h"
static NSString *CellTableIdentifier = @"MIKETableViewCell";
@implementation MIKETableViewCell
@synthesize timeLabel = _timeLabel;
@synthesize priceLabel = _priceLabel;
@synthesize infoLabel = _infoLabel;
- (void)awakeFromNib
{
// Initialization code
}
-(void)layoutSubviews
{
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognizer)];
[self addGestureRecognizer:panGesture];
}
-(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
}
-(void)panGestureRecognizer
{
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognizer)];
NSLog(@"Panned!");
CGPoint translation = [panGesture translationInView:self];
panGesture.view.center = CGPointMake(panGesture.view.center.x + translation.x,
panGesture.view.center.y + translation.y);
}
@end
感谢您的任何回答!
【问题讨论】:
标签: ios objective-c cocoa-touch uitableview