작성
·
272
답변 2
0
0
안녕하세요
강의 기준은 storyboard내부에 넣어놓은 셀일 경우에 가능한 상황이기 때문에
따로 만든 셀이라면 스토리보드로 연결이 안됩니다.
tableView안에 정의된 didSelectRowAt 이라는 걸 구현후에 그 안에 아래처럼 이동하는 코드를 넣어야 합니다.
그리고 sender안에 어떤걸 선택했는지 알아야 하니 indexPath를 같이 보내줘야 합니다.
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("showDetail", sender: indexPath)
}
이렇게 하면 prepare for segue에서 sender가 indexPath로 되는 로직으로 변경해야 됩니다.
if segue.identifier == "showDetail" {
let selectedIndexPath = sender as! IndexPath
여기서 selectedIndexPath.row로 모델의 어떤값을 사용할지 접근하면 됩니다.
}
도움되시길 바랍니다.