Swift-如何设置tableViewCell标签栏?

时间:2017-05-03 04:54:04

标签: swift tabbar

我在下面有这个课程

  class CategoryCell: UITableViewCell, UICollectionViewDelegate, 
                      UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
     ..... ...
 }

我还有一个tabbar控制器。我能够为集合视图类

设置一个选项卡
let searchNavController = templateNavController(
         unselectedImage:    #imageLiteral(resourceName: "search_unselected"), 
         selectedImage:      #imageLiteral(resourceName: "search_selected"), 
         rootViewController: BusinessSearchController(collectionViewLayout: UICollectionViewFlowLayout()))

但由于某种原因,我无法弄清楚出了什么问题或者如何设置类别单元格的标签。下面的代码显示了此错误

" Argument labels '(style:)' do not match any available overloads"

如何设置类别单元格的tabcontroller?

let homeNavController = templateNavController(
    unselectedImage: #imageLiteral(resourceName: "home_unselected"),
    selectedImage: #imageLiteral(resourceName: "home_selected"), 
    rootViewController: CategoryCell(style: .plain)

1 个答案:

答案 0 :(得分:0)

您无法设置UICollectionViewCell类型的标签。 BusinessSearchControllerUIViewController的一种类型,这就是您能够将其添加到UITabBarController的原因。基本上,对于标签栏,您需要ViewControllers而不是单元格。

   class CustomTabBarController: UITabBarController {
        override viewDidLoad() {
            // Tab bar class have a viewControllers Property
            viewControllers = [BusinessSearchController, ... your other controllers]
        }
   }