【问题标题】:XLPagerTabStrip: How to add different bar buttons for different tabs using ButtonBarPagerTabStripViewControllerXLPagerTabStrip:如何使用 ButtonBarPagerTabStripViewController 为不同的选项卡添加不同的栏按钮
【发布时间】:2017-09-09 11:22:28
【问题描述】:

我有三个选项卡,每个选项卡都有不同数量的 rightBarButtonItem 并且有不同的操作。

例如。第一个选项卡有两个右栏按钮电话和搜索,第二个选项卡有三个右栏按钮添加、删除和编辑,第三个选项卡有两个右栏按钮完成和更多。我不知道如何添加它。

请提出一些想法。提前致谢。

【问题讨论】:

    标签: swift rightbarbuttonitem xlpagertabstrip


    【解决方案1】:

    您可以在继承ButtonBarPagerTabStripViewControllerand的ViewController中添加以下函数检查toIndex是0或1或2,然后自定义您的rightBarButtonItems

    override func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) {
    
    if toIndex == 0 {
    
        self.navigationItem.rightBarButtonItems = nil
    
        // add new barButtons
    
    }
    else if toIndex == 1 {
    
        self.navigationItem.rightBarButtonItems = nil
    
        // add new barButtons
    
    
    }
    else {
    
        self.navigationItem.rightBarButtonItems = nil
    
        // add new barButtons
    }}
    

    【讨论】:

      猜你喜欢
      • 2017-03-19
      • 1970-01-01
      • 1970-01-01
      • 2018-06-29
      • 1970-01-01
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多