我有一个装满图像的 tableView。当用户点击图像(在单元格内)时,将调用具有较大可缩放图像版本的 viewController,并使用弹出框 segue。当我关闭弹出窗口并返回到我的 tableView 时,它会自动显示表格的顶部单元格。有什么办法可以阻止这种情况发生,并返回到调用弹出窗口之前的前一个位置/单元格?
编辑: 调用我使用的弹出窗口
performSegueWithIdentifier("segueToPopOver", sender: tap.view)
要关闭它,我使用以下内容:
let tmpController :UIViewController! = self.presentingViewController;
self.dismissViewControllerAnimated(true, completion: {()->Void in
tmpController.dismissViewControllerAnimated(true, completion: nil);
});
最佳答案
在显示 zoomViewController 之前获取 tableview 内容偏移量。
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
tableViewContentOffset = self.tableView.contentOffset;
}
并在 viewWillAppear 中再次设置 tableview 的偏移量
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView setContentOffset:tableViewContentOffset];
}
关于ios - 如何阻止 UITableView 在弹出后返回顶部单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34868661/