Swift-如何设置 tableViewCell 标签栏?

标签 swift tabbar

我有下面这个类(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 类型设置选项卡。 BusinessSearchControllerUIViewController 的一种类型,这就是您能够将其添加到 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/

相关文章:

ios - 从 IOS + Swift 将图像上传到 Socket.io 中的服务器

ios - 根据键值查询PFUser(Swift)

android - 设置选项卡的宽度

iphone - UITabBar全透明

ios - 在 iPad 上共享文件失败,错误代码为 "[ShareSheet] Failed to request default share mode for fileURL:..."

ios - 在不使用 Google Maps API 的情况下集成 Google Places API?

ios - Swift 3 - 如何在自定义 Tabbar 中使用 JSON 数组?

swift - 快速从 uiview 访问选项卡栏

android - 如何获得这个标签栏

ios - UILabel 新文本值未在 XCUITest 内更新