Hemant Suthar
Hemant Suthar

Reputation: 51

Customise moreNavigationController's tableview and similar user interface

I have overridden moreNavigationController tableview, but I want to use same row that is default as native moreNavigationController's tableview datasource(tabbaritem icon, name and badge etc.). I have tried to fetch cell from existing datasource. Below is my code snippet:

func tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool
{
    if (viewController == tabBarController.moreNavigationController && tabBarController.moreNavigationController.delegate == nil)
    {
        if tabBarController.moreNavigationController.topViewController?.view is UITableView
        {
            let view:UITableView = tabBarController.moreNavigationController.topViewController?.view as! UITableView

            tblDataSource = view.dataSource

            view.delegate = self

            view.dataSource = self
        }
    }

    return true
}


func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{

    let cell:UITableViewCell = tblDataSource?.tableView(tableView, cellForRowAtIndexPath: indexPath)
    return cell
}

But, it shows me blank cell.

Upvotes: 4

Views: 944

Answers (2)

Wolfgang Schreurs
Wolfgang Schreurs

Reputation: 11834

You need to implement the following method to properly display the cells for the "More" view controller:

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    tblDataSource?.tableView!(tableView, willDisplay: cell, forRowAt: indexPath)
}

Upvotes: 1

Sunil Chauhan
Sunil Chauhan

Reputation: 2084

Ok, I don't understand. If you want same rows as native, then why would you override UITableViewDataSource methods? Leave as it is. Override the necessary methods those you need.

Upvotes: 0

Related Questions