How replace a table view by a collection view?

333 views Asked by At

I want to replace a table view by a collection view, the table view is inside a tab from XLPagerTabStrip.

I already tried to replace some things but I get some errors, can someone put me on the right direction ?

import UIKit
import XLPagerTabStrip

class BooksChildViewController: UITableViewController, 
IndicatorInfoProvider {

    let cellIdentifier = "postCell"
    var blackTheme = false
    var itemInfo = IndicatorInfo(title: "Livros")

    init(style: UITableViewStyle, itemInfo: IndicatorInfo) {
        self.itemInfo = itemInfo
        super.init(style: style)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

    }

    // MARK: - IndicatorInfoProvider

    func indicatorInfo(for pagerTabStripController:
PagerTabStripViewController) -> IndicatorInfo {
        return itemInfo
    }

}
1

There are 1 answers

2
Rey Bruno On

Your class BooksChildViewController should inherit UICollectionViewController instead of UITableViewController.

Also, you need modify your init() . UICollectionViewController can be initializer with a UICollectionViewLayout instead with a style like UITableViewController.