-3

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
    }

}
  • If you need a Collectionview, why did you create a UITableViewController? Do you need to use both in your UI? You should inherit your Viewcontroller from simply UIViewController and make it adapt to both TableView and CollectionView delegates/datasource. – NSNoob Dec 28 '18 at 15:08

1 Answers1

0

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.

Rey Bruno
  • 334
  • 1
  • 13