ios – 自定义moreNavigationController的tableview和类似的用户
发布时间:2020-12-14 17:24:40 所属栏目:百科 来源:网络整理
导读:我已经覆盖了moreNavigationController tableview,但是我想使用默认为nativeNavigationController的tableview数据源的相同行(tabbaritem图标,名称和徽章等). 我试图从现有的数据源中获取单元格.以下是我的代码片段: func tabBarController(tabBarController
我已经覆盖了moreNavigationController tableview,但是我想使用默认为nativeNavigationController的tableview数据源的相同行(tabbaritem图标,名称和徽章等).
我试图从现有的数据源中获取单元格.以下是我的代码片段: 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 } 但是,它显示了我的空白细胞. 解决方法
您需要实现以下方法才能正确显示“更多”视图控制器的单元格:
func tableView(_ tableView: UITableView,willDisplay cell: UITableViewCell,forRowAt indexPath: IndexPath) { tblDataSource?.tableView!(tableView,willDisplay: cell,forRowAt: indexPath) } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |