I have programmatically implemented a tableView inside a viewController:
class MoviesViewController5: UIViewController {
let tableView = UITableView()
// There's a code responsible for populating this array
var moviesItemsArray = [[movieItem]]()
var sectionsData:[[String:Any]]?
let cellIdentifier = "movieCardCell"
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.register(sectionTableCell2.self, forCellReuseIdentifier: "tableViewCell")
displayTableView2()
}
func displayTableView2() {
self.view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
tableView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
tableView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
}
}
extension MoviesViewController5: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, canFocusRowAt indexPath: IndexPath) -> Bool {
return false
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 20
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell =
tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) as? sectionTableCell2
else {
fatalError("Unable to create explore table view cell")}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 140
}
}
The tableViewCell is also implemented programmatically:
class TableViewCell3: UITableViewCell {
var moviesItems: [movieItem] = []
let cellIdentifier = "movieCardCell"
var collectionViewTest:UICollectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: UICollectionViewFlowLayout())
fileprivate let cellOffset: CGFloat = 50
func setupCollectionView() {
collectionViewTest.delegate = self
// TODO: Should I communicate moviesItems to TableViewCell3 or set the dataSource to MoviesViewController 5
collectionViewTest.dataSource = self
}
}
// Trying to display only one collectionView in tableCell
extension TableViewCell3: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return moviesItems.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier:
cellIdentifier, for: indexPath) as! movieCardCell
cell.movieImageView.sd_setImage(with: URL(string: moviesItems[indexPath.item].imageURL))
return cell
}
}
WHAT I WANT TO IMPLEMENT:
Populate moviesItemsArray inside MoviesViewController5
Communicate each moviesItems of moviesItemsArray to each correspondant TableViewCell3 based on the index
Affect the received movie data to the class property moviesItems of TableViewCell3
Display the movies data inside the TableViewCell3 with the help of collectionViewTest
PROBLEM (STEP 2): I don't know how to communicate each moviesItems of moviesItemsArray to each correspondant TableViewCell3 based on the index.
NOTE: The other steps have already been taken care of.
QUESTION: Should I communicate the data like any communication between different classes in SWIFT OR there's something that needs to be done with collectionViewTest.dataSource inside the TableViewCell3
The question is how can I communicate the information to tableViewCell
That is what cellForRowAt is for. Your implementation is currently effectively empty:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) as? sectionTableCell2
else {
fatalError("Unable to create explore table view cell")
}
// HERE, THIS IS WHERE YOU DO IT
return cell
}
Just found an answer in a similar project:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let _cell = tableView.dequeueReusableCell(withIdentifier: tableCellIdentifier, for: indexPath) as? CatalogueTableViewCell {
// THIS
_cell.images = images[indexPath.section]
return _cell
} else {
return UITableViewCell()
}
}
Images is the property that's used for communicating:
class CatalogueTableViewCell: UITableViewCell {
internal var images: [UIImage]!
}
Related
I want to show image using sdWebImage to an image inside collectionView Cell which is inside tableView cell. How to do it ?
I have array of images and I want to show it in collection view cell
this is what I tried
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if let imgUrl = (myArray[indexPath.row] as? String)
{
//myArray = image array
if let url = URL(string: imgUrl as! String) {
cell.imgView.sd_setImage(with: url, placeholderImage: UIImage(named: "product.png"), options: .lowPriority)
}
}
}
I already set
func setCollectionViewDataSourceDelegate(dataSourceDelegate: UICollectionViewDataSource & UICollectionViewDelegate, forRow row: Int) {
collectionVIew.delegate = dataSourceDelegate
collectionVIew.dataSource = dataSourceDelegate
collectionVIew.tag = row
collectionVIew.reloadData()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DashboardTableViewCell") as! DashboardTableViewCell
cell.delegate = self
cell.selectedIP = indexPath
cell.collectionVIew.tag = indexPath.row
cell.collectionVIew.reloadData()
return cell
}
But I don't know how to show images inside collection view in particular tableview section.
Please Help.
Set Collection view Deleagte and dataSource inside the table view cellforRow method
collectionview.delegae = self
collectionview.datasource = self
As mention by #AjinkyaSharma You have to rearrange your data structure, where it would be an array of arrays.
let myImages: [[String]] = [
["image_url_0_0", "image_url_0_1", "image_url_0_2", "image_url_0_3"],
["image_url_1_0", "image_url_1_1", "image_url_1_2"],
["image_url_2_0", "image_url_2_1", "image_url_2_2", "image_url_2_3", "image_url_2_4"],
["image_url_3_0", "image_url_3_1"]
]
Now you tableview cellForRowAt will set the required array of images for collectionView
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return myImages.size
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DashboardTableViewCell") as! DashboardTableViewCell
cell.delegate = self
cell.selectedIP = indexPath
cell.collectionVIew.tag = indexPath.row
cell.myArray = myImages[indexPath.row]
cell.collectionVIew.reloadData()
return cell
}
Now you need to use your myArray array to display your collectionView cells
One of your url is not able to satisfy if let condition. Set default image to nil to make sure not to show any previous data.
Try This:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
cell.imgView.image = nil // set default image nil
if let imgUrl = (myArray[indexPath.row] as? String)
{
//myArray = image array
if let url = URL(string: imgUrl as! String) {
cell.imgView.sd_setImage(with: url, placeholderImage: UIImage(named: "product.png"), options: .lowPriority)
}
}
}
Try With Below Code
class YourCustomizeTableViewCell: UITableViewCell {
let collectionView: CollectionView
...
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "HorizontalSlideCell", for: indexPath) as! YourCustomizeTableViewCell
cell.collectionView.tag = indexPath.row
return cell
}
...
func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "InnerCollectionViewCell",
for: indexPath as IndexPath)
//indexPath.section is the collectionview section index but needs to be its parent tableview section's index. How do I get it?
cellCharLabel?.text =
Languages.sharedInstance.alphabets[collectionView.tag].set[indexPath.row].char
...
return cell
}
func setCollectionViewDataSourceDelegate<D:UICollectionViewDataSource & UICollectionViewDelegate>(datasourcedelegate : D, forRow row:Int){
collectionVIew.delegate = datasourcedelegate
collectionVIew.dataSource = datasourcedelegate
collectionVIew.tag = row
collectionVIew.isPagingEnabled = row == 0 ? false : true
collectionVIew.accessibilityHint = row == 0 ? "category" : "offers"
collectionVIew.reloadData()
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
guard let cell = cell as? DashboardTableViewCell else {
return
}
cell.setCollectionViewDataSourceDelegate(datasourcedelegate: self, forRow: indexPath.section)
}
extension HomeViewController : UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return array.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PopularCollectionViewCell.identifier, for: indexPath) as? PopularCollectionViewCell else {
return UICollectionViewCell()
}
cell.backgroundColor = .clear
cell.setValue(data: popularItemList[indexPath.row])
return cell
}
}
extension HomeViewController : UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width:120, height: itemWidth + 82)
}
}
After the tableView.reloadData() the visible collectionView display the first row unexpected immediately.
Im building a tableView contains collectionView in its cells, users can scroll multiple images in every single tableView just like Instagram. How can I fix it? Thanks!
tableView DataSource
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return photoRolls.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) as! HomeTableViewCell
if photoRolls.isEmpty {
return UITableViewCell()
}
let user: UserModel = users[indexPath.row]
let photoRoll: PhotoRoll = photoRolls[indexPath.row] //this Model contains post info: likes, comments etc.
let photoUrls: UrlStrings = urls[indexPath.row] //this Model contains a array of urlStrings for each collectionView inside the tableViewCell
cell.urlStrings = photoUrls
cell.photoRoll = photoRoll
cell.user = user
cell.delegate = self
return cell
}
prepareForReuse Method in tableViewCell
override func prepareForReuse() {
super.prepareForReuse()
captionLabel.text = nil
profileImage.image = UIImage(named: "placeholderImg")
profileImageRight.image = UIImage(named: "placeholderImg")
collectionView.scrollToItem(at:IndexPath(item: 0, section: 0), at: .left, animated: false)//tried to remove this method, but the collectionView would not display the first row when it's visible
}
DataSource of collectionView inside tableViewCell
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return cellUrlArray.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "HomeCollectionViewCell", for: indexPath) as! HomeCollectionViewCell
cell.url = cellUrlArray[indexPath.row]
return cell
}
Like the question title said. I expect the visible collectionView stays on the current row after the tableView load more data after tableView.reloadData() is called! Thanks again!
I think it is possible with contentOffset cacheing, like below
var cachedPosition = Dictionary<IndexPath,CGPoint>()
func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if let cell = cell as? HomeTableViewCell {
cachedPosition[indexPath] = cell.collectionView.contentOffset
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
<<Your Code>>
cell.collectionView.contentOffset = cachedPosition[indexPath] ?? .zero
return cell
}
So I'm having this issue that when reloadData() is called after the initial API call, it calls willDisplayCell method which when the last cell is displayed will load more data (API returns 10 data at a time).
However in the view it can show only 4 - 5 cells as I set the row height to 175 points manually. Does anyone know why is this happening?
If this is how the tableView works what can I do to make my tableView to load only 10 initially?
Following is my code.
class MainViewController: UIViewController {
var tableView: UITableView!
var photoViewmodel: PhotoViewModel!
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Home"
initTableView()
photoViewmodel = PhotoViewModel()
photoViewmodel.loadNewPhotos {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
func initTableView() {
tableView = UITableView.init(frame: self.view.frame, style: .plain)
tableView.delegate = self
tableView.dataSource = self
tableView.rowHeight = 175
tableView.separatorStyle = .none
tableView.register(HomeTableViewCell.nib, forCellReuseIdentifier: HomeTableViewCell.identifier)
view.addSubview(tableView)
}
}
extension MainViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return photoViewmodel.photos.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("cellForRowAt")
let cell = tableView.dequeueReusableCell(withIdentifier: HomeTableViewCell.identifier, for: indexPath) as! HomeTableViewCell
cell.tag = indexPath.row
cell.configureCell(url: photoViewmodel.photos[indexPath.row].regularImgUrl, cacheKey: indexPath.row)
return cell
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
print("willDisplay")
let lastCell = photoViewmodel.photos.count - 1
if indexPath.row == lastCell {
print("add 10 more photos")
photoViewmodel.loadNewPhotos(
DispatchQueue.main.async {
self.tableView.reloadData()
}
})
}
}
}
I have a TableView with two kind of Cells, both are filled with a CollectionView. In the TableViewController I let them them display with a simple if Statement.
My TableViewController:
import UIKit
import RealmSwift
import Alamofire
import SwiftyJSON
let myGroupLive = DispatchGroup()
let myGroupCommunity = DispatchGroup()
class HomeVTwoTableViewController: UITableViewController {
var headers = ["Live", "Channel1", "ChannelTwo", "Channel3", "Channel4", "Channel5", "Channel6"]
override func viewDidLoad() {
super.viewDidLoad()
DataController().fetchSomeDate(mode: "get")
DataController().fetchSomeOtherData(mode: "get")
}
//MARK: Custom Tableview Headers
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return headers[section]
}
override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int){
view.tintColor = UIColor.black
let header = view as! UITableViewHeaderFooterView
if section == 0 {
header.textLabel?.textColor = UIColor.black
view.tintColor = UIColor.white
}
else {
view.tintColor = UIColor.groupTableViewBackground
}
}
//MARK: DataSource Methods
override func numberOfSections(in tableView: UITableView) -> Int {
return headers.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
//Choosing the responsible PrototypCell for the Sections
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellBig", for: indexPath) as! HomeVTwoTableViewCell
return cell
}
else if indexPath.section == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellSmall", for: indexPath) as! HomeVTwoTableViewCellSmall
return cell
}
else {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellSmall", for: indexPath) as! HomeVTwoTableViewCellSmall
return cell
}
}
//Set custom cell height, has to match the CollectionView height
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0 {
return 225.0
}
else {
return 120.0
}
}
}
My TableViewCellSmall:
import UIKit
import RealmSwift
var communities: Results<Community>?
class HomeVTwoTableViewCellSmall: UITableViewCell{
#IBOutlet weak var collectionView: UICollectionView!
}
extension HomeVTwoTableViewCellSmall: UICollectionViewDataSource,UICollectionViewDelegate {
//MARK: Datasource Methods
func numberOfSections(in collectionView: UICollectionView) -> Int
{
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
return (communities?.count)!
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCellSmall", for: indexPath) as? HomeVTwoCollectionViewCellSmall else
{
fatalError("Cell has wrong type")
}
//Here I want my Sorting Statement to make unique content per collection view
//normal approach if no section is asked
let url : String = (communities?[indexPath.row].pictureUri)!
let name :String = (communities?[indexPath.row].communityName)!
cell.titleLbl.text = name
cell.imageView.downloadedFrom(link :"somelink")
return cell
}
//MARK: Delegate Methods
override func layoutSubviews() {
myGroupCommunity.notify(queue: DispatchQueue.main, execute: {
let realm = try! Realm()
communities = realm.objects(Community.self)
self.collectionView.dataSource = self
self.collectionView.delegate = self
})
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
do something
}
}
My Problem is now, I want the "Channel Cells" to fill with customized and different data, in the CollectionView. That means I need some sort of key to get the right data in the right cell. My approach would be to take the SectionHeader Title, but for some reasons I cant access it from the TableViewCellSmall. So I have all the data in all the Cells and cant sort them without my Key.
Thanks in Advance.
from what I understand you need to fill the collectionview of each cell with different contents and for this needs to identify the cell?
If so, I used the method below that helped me, you can try.
If in doubt let me know so I can help, I hope I have helped :)
//TableViewCell Add
var didCollectionViewCellSelect: ((Int) -> Void)?
override func setSelected(_ selected: Bool, animated: Bool)
{
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
//TabelView Add
class myClass: UITableViewController
{
var storedOffsets = [Int: CGFloat]()
override func viewDidLoad()
{
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
{
guard let tableViewCell = cell as? myTableViewCell else { return }
let secao = indexPath.section*1000 //Section
let linha = indexPath.row //Row
let posicao = secao+linha
tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: posicao)
tableViewCell.collectionViewOffset = storedOffsets[posicao] ?? 0
}
override func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath)
{
guard let tableViewCell = cell as? myTableViewCell else { return }
let secao = indexPath.section*1000 //Section
let linha = indexPath.row //Row
let posicao = secao+linha
storedOffsets[posicao] = tableViewCell.collectionViewOffset
}
}
//CollectionView
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
let posicao = collectionView.tag
let secao = Int(collectionView.tag/1000) //Section
let linha = posicao-(secao*1000) //Row
var qtd = 0
if secao == 0 && arrStation.count > 0
{
qtd = arrStation.count
}
return qtd
}
After hours of googling it seems that I need a hint from society.
So the problem is:
I have two custom prototype cells. First one contains UICollectionView with 12 cells, second one contains only a label.
My task is to pass indexPath.row from that collectionView from first cell to the label from the second cell.
didSelectItemAtIndexPath: not working or I didn't tuned it properly.
Any ideas on how to implement will be very appreciated!
Here's my code (sorry for poor StackOverflow formatting)
import UIKit
class MainTableViewController: UITableViewController {
var storedOffsets = [Int: CGFloat]()
var descrLabel = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .LightContent
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCellWithIdentifier("MainCell", forIndexPath: indexPath) as! MainTableViewCell
let bgImg = UIImageView(image: UIImage(named: "background"))
bgImg.contentMode = UIViewContentMode.ScaleAspectFill
cell.backgroundView = bgImg
return cell
}
else {
let cell = tableView.dequeueReusableCellWithIdentifier("DescriptionCell", forIndexPath: indexPath) as! DescriptionTableViewCell
cell.descriptionLabel.text = self.descrLabel.text
return cell
}
}
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
guard let tableViewCell = cell as? MainTableViewCell else { return }
tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.row)
tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? 0
}
override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
guard let tableViewCell = cell as? MainTableViewCell else { return }
storedOffsets[indexPath.row] = tableViewCell.collectionViewOffset
}
}
extension MainTableViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 12
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("MainCollectionViewCell", forIndexPath: indexPath) as! MainCollectionViewCell
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("Collection view at row \(collectionView.tag) selected index path \(indexPath.row)")
self.descrLabel.text = "testText"
}
}
I played around in playground and made this.
It's not tested, but it should give you idea.
protocol CustomDelegate{
func passData(data: AnyObject)
}
class CustomColletionView : UICollectionView, UICollectionViewDelegate{
var customDelegate : CustomDelegate!
func didSelectItemAtIndexPath(collectionView : UICollectionView, indexPath : NSIndexPath){
let cell = collectionView.cellForItemAtIndexPath(indexPath)
let someData = ""
customDelegate.passData(someData)
}
}
class ViewController: UITableViewController, CustomDelegate{
var labelCellData : AnyObject?{
didSet{
//reloadCell when data is received
tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: 1, inSection: 0)], withRowAnimation: .Bottom)
}
}
func passData(data: AnyObject) {
labelCellData = data
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.registerClass(CustomTableViewCell.self, forCellReuseIdentifier:"Indetifier1")
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "simpleCell")
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch indexPath.row{
case 0:
//this should contain CustomCollectionView
let cell = tableView.dequeueReusableCellWithIdentifier("Indetifier1") as! CustomTableViewCell
cell.collectionView.customDelegate = self
return cell
case 1:
let cell = tableView.dequeueReusableCellWithIdentifier("simpleCell")
cell?.textLabel?.text = labelCellData as? String
return cell!
default:
break
}
return UITableViewCell()
}
}
class CustomTableViewCell: UITableViewCell {
var collectionView : CustomColletionView!
// You need to implement it
}