我有一個特定單元格的手勢表格視圖。在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