Objective c 编辑indexPath.row后是否在UITableView中更新分段顺序?
在编辑了序列的顺序(indexPath.row)之后,如何使序列仍然连接到行?现在,当我更改了行的顺序时,当然,序列会转到错误的视图。。。 提前谢谢。这是相关代码Objective c 编辑indexPath.row后是否在UITableView中更新分段顺序?,objective-c,tableview,segue,didselectrowatindexpath,Objective C,Tableview,Segue,Didselectrowatindexpath,在编辑了序列的顺序(indexPath.row)之后,如何使序列仍然连接到行?现在,当我更改了行的顺序时,当然,序列会转到错误的视图。。。 提前谢谢。这是相关代码 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { NSString *stringToMov
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
NSString *stringToMove = self.objects[sourceIndexPath.row];
[self.objects removeObjectAtIndex:sourceIndexPath.row];
[self.objects insertObject:stringToMove atIndex:destinationIndexPath.row];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text=self.objects[indexPath.row];
return cell;
}
//segues
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Conditionally perform segues, here is an example:
if (indexPath.row == 0)
{
[self performSegueWithIdentifier:@"segue 1" sender:self];
}
else if (indexPath.row ==1
{
[self performSegueWithIdentifier:@"segue 2" sender:self];
}
else if (indexPath.row ==2)
{
[self performSegueWithIdentifier:@"segue 3" sender:self];
}
}
@end
(“对象”是具有存储行的NSarray。)解决方案:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *segueRow = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; segueRow.textLabel.text=self.objects[indexPath.row];
if ([segueRow.textLabel.text isEqualToString:@"segue 1"])
{ [self performSegueWithIdentifier:@"white" sender:self];
} else if ([segueRow.textLabel.text isEqualToString:@"segue 2"])
{
没关系,我是这样修复的:
static NSString*CellIdentifier=@“Cell”;UITableViewCell*segueRow=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];segueRow.textlab.text=self.objects[indexPath.row];如果([segueRow.textLabel.text IsequalString:@“segue 1”]){[self-PerformsgueWithIdentifier:@“white”发件人:self];}如果([segueRow.textLabel.text IsequalString:@“segue 2”]){