我在下面有这个课程
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)
答案 0 :(得分:0)
您无法设置UICollectionViewCell
类型的标签。 BusinessSearchController
是UIViewController
的一种类型,这就是您能够将其添加到UITabBarController
的原因。基本上,对于标签栏,您需要ViewControllers
而不是单元格。
class CustomTabBarController: UITabBarController {
override viewDidLoad() {
// Tab bar class have a viewControllers Property
viewControllers = [BusinessSearchController, ... your other controllers]
}
}