Created
March 29, 2018 08:47
-
-
Save KC-218/a80c995583064974d9f228b47c2c5ef8 to your computer and use it in GitHub Desktop.
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
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell: CustomCell = CustomCell() | |
cell.button.addTarget(self, action: #selector(buttonClicked(sender:)), for: .touchUpInside) | |
} | |
func buttonClicked(sender: UIButton) { | |
let tapLocation = sender.convert(CGPoint.zero, to: tableView) //取得按鈕位置 | |
let tapIndexPath = self.tableView.indexPathForRow(at: tapLocation) //這個位置位於哪個indexPath | |
print(tapIndexPath.row) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment