我正在使用View pager应用程序制作一个应用程序,正在使用XLPagerTabStrip库来制作它。与Viewpager项中的“标题”一起使用时效果很好。我想在其中添加图标和相应的标签。

最佳答案

崩溃背后的原因是,ButtonCell.xib中缺少UIImageView。

解决方法是:

  • 打开ButtonBarViewCell类,从xcode的顶部导航菜单中,单击ButtonBarViewCell。在那里您可以看到ButtonCell.xib。
  • 打开ButtonCell.xib,将UIImage视图拖放到单元格的中心。应用Constrains。并将其连接到IBOutlet imageView。
  • 返回ButtonBarViewCell类,并在其中添加以下代码行
    func willMove(toSuperview newSuperview:UIView?)函数。

  • 如果imageView.superview!= nil {
    contentView.addSubview(imageView)
    }

    4.返回实现页面的类并添加此代码
     func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return IndicatorInfo(title: "",image: UIImage(named: "camera.png"))
    }
    

    5.完成

    `

    10-08 07:30
    查看更多