Configure moreNavigationController tableview and similar user interface

I redefined moreNavigationControllertableview, but I want to use the same row, which by default is used as the native moreNavigationControllertableview datasource (tabbaritem icon, name and icon, etc.). I tried to extract a cell from an existing data source. The following is a snippet of code:

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 an empty cell.

+4
source share
2 answers

To display the cells for the More controller correctly, you need to implement the following method:

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

, . , , UITableViewDataSource? , . , .

0

Source: https://habr.com/ru/post/1618263/


All Articles