2016-08-01 7 views
0

안녕하세요 모두들 여기에 문제가 있습니다. 가능한 한 최선을 다해 설명하려고 노력할 것입니다. 그래서 콜렉션 뷰 셀을 가진 콜렉션 뷰가 있고 그 셀 내부에 임베디드 테이블 뷰가 내장되어 있으며 테이블 뷰를 사용하면 3 개의 테이블 뷰를 리턴 할 3 개의 셀 (앞으로 더 많은 테스트를 위해)을 반환하고자합니다. 이러한 테이블 뷰를 통해 여러 유형의 데이터를 갖기를 원하지만 어떻게 할 수 있는지 또는 가능한 한 내 스토리 보드에서 테이블보기 하나만으로 가능한지 알고 싶습니다. 나는 이미 이것을 시도했지만 모든 것이 무효로 돌아 간다. 미리 감사드립니다!단일 콜렉션 뷰 셀 내에서 테이블보기 제어

func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
    // #warning Incomplete implementation, return the number of sections 
    if tableView == tableview1 { 

     return 0; 

    } else if tableView == tableview2 { 

     return 3 
    } 

    return 0; 
} 

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    // #warning Incomplete implementation, return the number of rows 
    if tableView == tableview1 { 
     return 2; 

    } else if tableView == tableview2 { 

     return 1; 
    } 
    return 0; 

} 



func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) 
    if tableView == tableview1 { 
     cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) 

    } else if tableView == tableview2 { 

     cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) 
    } 

    // Configure the cell... 
    if tableView == tableview1 { 

     cell.textLabel?.text = "Homeroom" 
     cell.detailTextLabel?.text = "8:15 AM - 9:00 AM" 
     cell.selectionStyle = .None 

    } else if tableView == tableview2 { 
     cell.textLabel?.text = "Test Table 2 " 
     cell.detailTextLabel?.text = "1:30 PM - 2:30 PM" 
     cell.selectionStyle = .None 

    } 

    return cell 

} 

답변

0

xibs 또는 storyboard를 사용하여 셀에 tableviews를 추가하십시오. 이러한 모든 델리게이트와 테이블 뷰의 데이터 소스를 collectionviewcell 클래스에 넣고,이 클래스에 데이터 소스와 델리게이트가 있음을 tableview에 알려줍니다. 그게 작동하는지 알려주세요.

관련 문제