ios - 自定义 moreNavigationController 的 tableview 和类似的用户界面

标签 ios iphone xcode swift uitabbarcontroller

我已经重写了 moreNavigationController tableview,但我想使用与 native moreNavigationController 的 tableview 数据源(tabbaritem 图标、名称和角标(Badge)等)默认相同的行. 我试图从现有数据源中获取单元格。下面是我的代码片段:

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
}

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

最佳答案

您需要实现以下方法才能正确显示“更多” View Controller 的单元格:

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

关于ios - 自定义 moreNavigationController 的 tableview 和类似的用户界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34040673/

相关文章:

iphone - 串联添加和删除 subview

ios - swift 2 : Cannot invoke initializer for type 'NSString'

ios - UIView 和 UIViewController

ios - 预加载 Sprite 套件纹理

android - 在Flutter中的for循环中使用时如何更改OnTap函数中的值

iphone - 使用 TPKeyboardAvoidingScrollView 移动键盘的文本字段不起作用

ios - Cordova-IOS 如何获取 iPhone UUID 或替代标识符

ios - 在 xcode 中设置 C 编译标志

swift - Collection View 单元格按钮未触发操作

ios - 在 cocoapod 中使用多个 Assets 目录