我有下面这个类(class)
class CategoryCell: UITableViewCell, UICollectionViewDelegate,
UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
..... ...
}
我还有一个标签栏 Controller 。我能够为 Collection View 类设置一个选项卡
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"
如何设置类别单元格的选项卡 Controller ?
let homeNavController = templateNavController(
unselectedImage: #imageLiteral(resourceName: "home_unselected"),
selectedImage: #imageLiteral(resourceName: "home_selected"),
rootViewController: CategoryCell(style: .plain)
最佳答案
您无法为 UICollectionViewCell
类型设置选项卡。 BusinessSearchController
是 UIViewController
的一种类型,这就是您能够将其添加到 UITabBarController
的原因。基本上,对于标签栏,您需要 ViewControllers
而不是单元格。
class CustomTabBarController: UITabBarController {
override viewDidLoad() {
// Tab bar class have a viewControllers Property
viewControllers = [BusinessSearchController, ... your other controllers]
}
}
关于Swift-如何设置 tableViewCell 标签栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43751360/