如何阻止UITableView在弹出后返回顶部单元格 [英] How to stop UITableView from returning to top cell after popover

查看:126
本文介绍了如何阻止UITableView在弹出后返回顶部单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个充满图像的tableView。当用户点击图像(在单元格内)时,使用popover segue调用具有较大可缩放版本图像的viewController。当我解除弹出窗口并返回到我的tableView时,它会自动显示表格的顶部单元格。有没有办法阻止这种情况发生,并在调用popover之前返回上一个位置/单元格?

I have a tableView full of images. When a user taps on an image (within the cell), a viewController with a larger zoomable version of the image is called with a popover segue. When i dismiss the popover and return to my tableView, it automatically displays the top cell of the table. Is there any way to stop this happening, and return to the previous position/cell before the popover was called?

编辑:
要调用我使用的popover

To call the popover i use

performSegueWithIdentifier("segueToPopOver", sender: tap.view)

解雇它我使用以下内容:

to dismiss it i use the following:

 let tmpController :UIViewController! = self.presentingViewController;


 self.dismissViewControllerAnimated(true, completion: {()->Void in
        tmpController.dismissViewControllerAnimated(true, completion: nil);
    });


推荐答案

在显示zoomViewController之前获取tableview内容偏移量。

Get tableview content offset before displaying your zoomViewController.

-(void)viewWillDisappear:(BOOL)animated {

  [super viewWillDisappear:animated];

  tableViewContentOffset = self.tableView.contentOffset;

}

并在viewWillAppear中再次设置tableview偏移量

and set tableview offset again in viewWillAppear

-(void)viewWillAppear:(BOOL)animated {

   [super viewWillAppear:animated];

   [self.tableView setContentOffset:tableViewContentOffset];
 }

这篇关于如何阻止UITableView在弹出后返回顶部单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆