编辑模式下的表格视图单元格未显示第一个元素附件

时间:2014-05-30 10:48:06

标签: ios uitableview

当我运行我的程序时,我将其作为输出,有人请帮助我。 enter image description here

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {

        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {

        // Return the number of rows in the section.
        return [[self.conversionParametersObject gettingArrayFunction] count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

        static NSString *CellIdentifier = @"Select Type";
        MyCustomCell *cell = (MyCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
        cell.showsReorderControl = YES;

        // Configure the cell...
        cell.mainSelectorParameterLabel.text =[mainSelectorObjects objectAtIndex:indexPath.row];

        return cell;
    }

    - (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Detemine if it's in editing mode
        if (self.tableView.editing)
        {
            return UITableViewCellEditingStyleNone;
        }

        return UITableViewCellEditingStyleNone;
    }

    // For the Moving of Rows, Apple default delegate methods

    -(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
    {

        if(indexPath.row == 0)
        {
            return NO; // Not Moving the first row
        }


        return  YES;
    }

    -(void) tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
    {

        NSString *stringToMove = [mainSelectorObjects objectAtIndex:sourceIndexPath.row];
        [mainSelectorObjects removeObjectAtIndex:sourceIndexPath.row];
        [mainSelectorObjects insertObject:stringToMove atIndex:destinationIndexPath.row];

    }

    -(NSIndexPath *) tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
    {
        NSDictionary *section = [mainSelectorObjects objectAtIndex:sourceIndexPath.section];
        NSUInteger sectionCount = [mainSelectorObjects count];
        if (sourceIndexPath.section != proposedDestinationIndexPath.section) {
            NSUInteger rowInSourceSection =
            (sourceIndexPath.section > proposedDestinationIndexPath.section) ?
            0 : sectionCount - 1;
            return [NSIndexPath indexPathForRow:rowInSourceSection inSection:sourceIndexPath.section];
        } else if (proposedDestinationIndexPath.row >= sectionCount) {
            return [NSIndexPath indexPathForRow:sectionCount - 1 inSection:sourceIndexPath.section];
        }
        // Allow the proposed destination.
        return proposedDestinationIndexPath;
    }

2 个答案:

答案 0 :(得分:0)

在您的代码中,MoveRowAtIndexPath方法代码可能会影响您编写的第一行(如果它是第一行),那么您将返回NO。评论/删除,然后重试。

答案 1 :(得分:0)

你应该这样使用,

-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    return  YES;
}