添加新细胞的第3细胞之后的细胞重复数据

时间:2013-10-29 06:59:28

标签: ios iphone objective-c uitableview

我正在开发一个图像编辑iPhone应用程序。我正在使用UITableView。我的问题是,当我在表视图中插入新行时,第3个单元格之后的新表视图单元格会重复第1个单元格的数据。

我必须进行大量搜索,但遗憾的是无法找到解决方案。任何人都可以查看我的代码并告诉我哪里出错了吗?

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"cell";
    VerticalFrameCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[VerticalFrameCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.imgView.image   = nil;
        cell.tf_Comment.text = nil;
    }

    //add gesture on picture
    UITapGestureRecognizer *imageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapHandlert:)];
    imageTap.delegate    = self;
    [cell.imgView addGestureRecognizer:imageTap];
    //add pinch gesture for zooming image
    UIPinchGestureRecognizer* pinchRecognizer =
    [[UIPinchGestureRecognizer alloc] initWithTarget:self
                                              action:@selector(handlePinch:)];
    pinchRecognizer.delegate        = self;
    [cell.imgView addGestureRecognizer:pinchRecognizer];


    //add pan gesture for plcing text
    UIPanGestureRecognizer *moveText = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(moveTextOnImge:)];
    moveText.delegate       = self;
    [moveText setMinimumNumberOfTouches:1];
    [moveText setMaximumNumberOfTouches:1];
    [cell.tf_Comment addGestureRecognizer:moveText];




    cell.imgView.tag            = indexPath.row+6000;
    cell.sclView.tag            = indexPath.row+7000;
    cell.btnAddText.tag         = indexPath.row+8000;
    cell.tf_Comment.tag         = indexPath.row+9000;

    return cell;
}

//在此处添加新的单元格代码

- (IBAction)btnAddNewCell_Action:(id)sender {
    if (objectsArray.count<6) {// not add more then six cell 
        [objectsArray addObject:@"Other's"];
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:objectsArray.count-1 inSection:0];
        [tbl_Frame insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];
        [tbl_Frame  scrollToRowAtIndexPath:indexPath  atScrollPosition:UITableViewScrollPositionBottom animated:YES];
    }else{
        [AppUtility displayAlertWithTitle:AlertTitle AndMessage:@"You can't take more then six images"];
    }
}

0 个答案:

没有答案