我有两个 View Controller :ViewControllerA
和 ViewControllerB
ViewControllerA
有一个包含很多单元格的 UITable。每个单元格都有一个按钮。当您单击单元格按钮时,它会导航到 ViewControllerB
像这样:
[[cell nav] setTag:indexPath.row];
[cell.nav addTarget:self action:@selector(naviguate:) forControlEvents:UIControlEventTouchUpInside];
cell.nav.tag=indexPath.row;
在哪里
nav
是按钮。并导航包含[self performSegueWithIdentifier:@"link" sender: sender];
链接是来自ViewControllerA
的segue 在哪里至ViewControllerB
然后我导航回
ViewControllerB
使用 performSegue
它回到了表的顶部!有什么办法可以保留ViewControllerA
在与我离开它的位置相同的位置?
最佳答案
你不想做循环转场。您每次都将创建一个新的 ViewControllerA。
您应该使用 dismissViewController:animated:
或 popViewControllerAnimated:
而是回到 A。 ViewControllerA 将和以前一样,因为它是同一个 VC 而不是重新创建的。
关于ios - 将 View Controller 保持在与左侧相同的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23921290/