我有一个特定单元格的手势表格视图。在tableview加载后,我滚动到第四行并向左滑动,它会显示一些内容,它的工作正常。但在此之后,当我回到第一排时,它也在第四排显示相同的内容。在第四行更改内容时,uitableview单元格更改第一行中的内容
当我用ios8运行这个代码时,它的工作正常。以上问题仅在我在ios7中运行时发生。
我的代码如下:提前
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SampleViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if(cell == nil)
{
cell = [[SampleViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
NSMutableDictionary *cellData = [self.databaseCall transactionFromDatabase:indexPath.row Id:self.Id andStageId:self.stageId];
[self setSelectedSegmentColor:cell.repeat];
cell.Description.text = self.Name;
cell.actionDescription.text = self.Name;
cell.tipsDescription.text = [cellData objectForKey:@"tipsDescription"];
UIImage *cellImage = [UIImage imageNamed:[cellData objectForKey:@"categoryImage"]];
NSLog(@"%@", [cellData objectForKey:@"cardType"]);
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[cellData objectForKey:@"actionLink"]];
if([[cellData objectForKey:@"cardType"] isEqualToString:@"2"])
{
UISwipeGestureRecognizer *swipeLeftGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftMethod:)];
swipeLeftGesture.direction = UISwipeGestureRecognizerDirectionLeft;
[cell.cardDetails addGestureRecognizer:swipeLeftGesture];
[cell.tryThisButton addTarget:self action:@selector(tryThisButtonPressed:) forControlEvents:UIControlEventTouchDown];
UISwipeGestureRecognizer *swipeRightGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightMethod:)];
swipeRightGesture.direction = UISwipeGestureRecognizerDirectionRight;
[cell.actionCardReminder addGestureRecognizer:swipeRightGesture];
[cell.previousButton addTarget:self action:@selector(previousButtonPressed:) forControlEvents:UIControlEventTouchDown];
}
else
{
for(UIGestureRecognizer *recognizer in cell.cardDetails.gestureRecognizers)
{
[cell.cardDetails removeGestureRecognizer:recognizer];
}
for(UIGestureRecognizer *recognizer in cell.actionCardReminder.gestureRecognizers)
{
[cell.actionCardReminder removeGestureRecognizer:recognizer];
}
cell.cardDetails.layer.shadowColor = [UIColor blackColor].CGColor;
cell.cardDetails.layer.shadowOffset = CGSizeMake(0, 2);
cell.cardDetails.layer.shadowOpacity = 0.5;
}
cell.weburl.attributedText = str;
cell.Name.text = self.Name;
cell.Image.image = cellImage;
NSLog(@"%d", indexPath.row);
// Configure the cell...
return cell;
}
感谢。
哪些特定内容发生变化? – 2014-12-04 18:33:08
@LyndseyScott - 在第四行向左滑动也会在第一行向左滑动。 – 2014-12-05 04:15:06