Created
June 29, 2017 07:27
-
-
Save sebastienwindal/55c17c34cbe97a4cc6e253dc3685fb5d to your computer and use it in GitHub Desktop.
index path from cell or button inside a cell in prepareforsegue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
super.prepare(for: segue, sender: sender) | |
var indexPath:IndexPath? = nil | |
if let cell = sender as? UITableViewCell { | |
indexPath = tableView.indexPath(for: cell) | |
} | |
if let button = sender as? UIButton { | |
let buttonFrame = button.convert(button.bounds, to:tableView) | |
indexPath = tableView.indexPathForRow(at: buttonFrame.origin) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment