当我运行我的程序时,我将其作为输出,有人请帮助我。
- (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;
}
答案 0 :(得分:0)
在您的代码中,MoveRowAtIndexPath方法代码可能会影响您编写的第一行(如果它是第一行),那么您将返回NO。评论/删除,然后重试。
答案 1 :(得分:0)
你应该这样使用,
-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}