将viewcontroller保持在与左边相同的位置

max*_*sme 1 objective-c uitableview ios

我有两个viewcontrollers:ViewControllerAViewControllerB

ViewControllerA有一个有很多细胞的UITable.每个单元格都有一个按钮.当您单击单元格按钮时,它会导航到ViewControllerB这样:

[[cell nav] setTag:indexPath.row];
[cell.nav addTarget:self action:@selector(naviguate:) forControlEvents:UIControlEventTouchUpInside];
cell.nav.tag=indexPath.row;
Run Code Online (Sandbox Code Playgroud)

nav按钮在哪里.而naviguate包含[self performSegueWithIdentifier:@"link" sender: sender];其中的环节是从赛格瑞ViewControllerAViewControllerB

当我然后导航回ViewControllerB使用performSegue它回到表的顶部!有没有办法保持ViewControllerA与我离开的位置相同的位置?

Tom*_*voy 5

你不想做圆形的细分.您每次都会创建一个新的ViewControllerA.

您应该使用dismissViewController:animated:popViewControllerAnimated:返回A代替.ViewControllerA将与以前一样,因为它是相同的VC而不是重新创建的VC.