2016-08-01 2 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を使用してセルにテーブルビューを追加します。これらすべてのデリゲートとtableviewのデータソースをcollectionviewcellクラスの中に入れて、そのクラスのデータソースとデリゲートがこのクラスにあることをtableviewsに伝えます。そのことができたら教えてください。

関連する問題