3D Touch Peek in invert table view cell

I have a chat application in which I use the inverted table view method (the table view is scaled to (1, -1) with conversion, and all cells themselves also have a scale of (1, -1) neutralizing the effect, thereby effectively inverting the view tables to display the "first" cell at the bottom) to "start" the presentation of the table below. Everything works fine, except that I need to implement drop-in and pop-gesture. I connected the button inside the cell of the lookup table to the target view controller and enabled peek and pop, as shown:

enter image description here

The gesture works, although when I touch 3D partially and hold enough to select the affected element (but not set the preview controller), I get an inverted view:

enter image description here

How can I make a view with the correct transform while still using the view with an inverted table?

+4
source share
1 answer

The reason it shows the view upside down after a light click is not because it removes the transform from the cell. In fact, the transformation in the cell remains as soon as, but segue pulls the cell view out of the context of the tableView. Therefore, the conversion in the cell no longer counteracts the conversion in the table.

, , UIStoryboardSegue, , , . .

, :

func updateTableContentInset() {
    let numRows = tableView(self.tableView, numberOfRowsInSection: 0)
    var contentInsetTop = self.tableView.bounds.size.height - (self.navigationController?.navigationBar.frame.size.height)! - 20
    for i in 0..<numRows {
        let rowRect = self.tableView.rectForRow(at: IndexPath(item: i, section: 0))
        contentInsetTop -= rowRect.size.height
        if contentInsetTop <= 0 {
            contentInsetTop = 0
        }
    }
    self.tableView.contentInset = UIEdgeInsetsMake(contentInsetTop, 0, 0, 0)
}

UITableViewController viewDidLoad() , .

updateTableContentInset() :

tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)

, Peek segue.

+2

Source: https://habr.com/ru/post/1695415/


All Articles