[iOS] Cell의 indexPath 값을 얻는 방법

Logan·2020년 12월 1일
1

Cell의 indexPath

let indexPath = tableView.indexpath(for: cell)

Cell 내부에 있는 객체의 위치를 indexPath로 변환


// 객체를 button(버튼)이라고 가정할 경우

let selectedButtonPositon: CGPoint = button.convert(.zero, to: tableView)
guard let selectedIndexPath = tableView.indexPathForRow(at: selectedButtonPositon) else { return }
profile
iOS개발자 꿈나무

0개의 댓글