【问题标题】:Customise moreNavigationController's tableview and similar user interface自定义moreNavigationController的tableview和类似的用户界面
【发布时间】:2015-12-02 10:41:21
【问题描述】:

我已经覆盖了moreNavigationController tableview,但我想使用默认为原生moreNavigationController 的tableview 数据源的同一行(tabbaritem 图标、名称和徽章等)。 我试图从现有数据源中获取单元格。下面是我的代码sn-p:

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
}

但是,它显示了空白单元格。

【问题讨论】:

  • “moreNavigationControlle”是什么意思?
  • moreNavigationController 是第 5 个选项卡 ViewController 如果 UITabviewController 包含五个以上的选项卡。参考developer.apple.com/library/ios/documentation/UIKit/Reference/…
  • 您的问题可以与您的问题的其他描述有关。
  • 这个问题你解决了吗?

标签: ios iphone xcode swift uitabbarcontroller


【解决方案1】:

您需要实现以下方法才能正确显示“更多”视图控制器的单元格:

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

【讨论】:

    【解决方案2】:

    好吧,我不明白。 如果您想要与本机相同的行,那么为什么要覆盖 UITableViewDataSource 方法?保持原样。覆盖您需要的必要方法。

    【讨论】:

    • 我需要一个选项卡的 shouldSelectViewController 的返回值为 false。这就是为什么我必须覆盖它。
    猜你喜欢
    • 2015-12-24
    • 2020-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多