2017-09-07 16 views
0

컨트롤러가 3 개 있습니다. 첫 번째 CollectionViewController, 다음 TableViewController 및 마지막 CollectionViewController. 첫 번째와 두 번째 컨트롤러는 json을 완벽하게 통과했습니다. 하지만 tableViewController didSelect가 작동하지 않습니다.스위프트 : TableViewController didSelectRowAt Index_path 함수가 작동하지 않습니다.

첫 collectionViewController

override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 

      let controller1 = ListTableView() 

      controller1.product_id = arrCategory[indexPath.item].id! 

      navigationController?.pushViewController(controller1, animated: true) 

} 

아마 문제가

재정의 FUNC의있는 tableView 코드를 여기에 두 번째 tableViewController (_있는 tableView : jQuery과, didSelectRowAt indexPath : IndexPath) {

let 레이아웃 = UICollectionVi ewFlowLayout()

  let controller1 = DescriptionCollectionView(collectionViewLayout: layout) 

    controller1.product_id = arrProduct[indexPath.item].id! 

    navigationController?.pushViewController(controller1, animated: true) 

}

JSON 웹 코드 내가 예를 아래에, 당신은 분명히 코드 prepareForSegue를 사용하는 것이 좋습니다 3 더 collectionViewController

enter image description here

답변

-1

없습니다 :

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if (segue.identifier == "yourSegueIdentifier") { 
     let controller = (segue.destination as! UINavigationController).topViewController as! YourSecondViewController //with UINavigationController as top view 

     controller.valueFromSecondController = self.valueFromThisController 
    } 
} 
(210)

그런 다음 didSelect 기능에 바로 전화 :

performSegue(withIdentifier: "yourSegueIdentifier", sender: row) 

희망이 도움이됩니다.

+0

segue가 프로그래밍 방식으로 신속하게 작동하지 않습니다. 여기서 모든 코드를 프로그래밍하고 있습니다. –

+0

프로그래밍 방식을 사용하고 있습니까? –

+0

프로그래밍 방식으로 세그먼트에 단절이 있습니다. –