1

What I want to do: Make UITableView selected row animate like a UIPickerView on selection.

I have a UITableViewController in which I am displaying UIImages in rows from Parse backend. The cell size is almost half of the users screen. I have used tapGestureRecognizer "Single Tap" to increase/decrease the cell height to show selected cell images and "Double Tap" to segue data to next view. If anyone is interested to know, here is the Link to it.

Now the problem is, when I tap on any specific cell image the cell increases in height as needed but if the selected cell is not centered when tapped (i.e: I have bottom half of the cell Row-1 and top half of cell Row-2 on users screen) the cell which has its height increased is partially visible.

So I was wondering if there is way with which we can have the selected cell automatically centered on tap? Similar to UIPickerView?

1 Answer 1

0

Here is a solution. Use the didSelectRowAtIndexPath delegate method and then scroll to the provided indexpath.row of the tableview accordingly.

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    yourTableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Top , animated: true)
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.