【问题标题】:Adding new Tab Bar on a tabbed page在标签页上添加新的标签栏
【发布时间】:2018-10-18 09:19:17
【问题描述】:

我正在尝试制作如下图所示的应用程序(ForeFlight),但我找不到任何解决方案来在标签页中添加新的标签页。

【问题讨论】:

  • 您尝试做某事通常是一个非常好的消息。但是,StackOverflow 的具有超感官天赋的员工目前不可用,因此,请向我们提供您已经尝试过的内容。
  • 请在提出新问题之前阅读here。无论如何,它似乎只是标签栏控制器内的一个分段控件。

标签: ios swift


【解决方案1】:

您可以简单地将内部选项卡设为 UIColllectionView。当 collectionView 中的一个单元格被选中时,您会使用新数据填充表格视图并重新加载它。

【讨论】:

    【解决方案2】:

    您可以在此处使用解决方法,例如创建 UIButtonUIStackView 并使用 AutoLayout 放置 stackView

    现在您可以默认选择 第一个按钮

    1. 更改按钮的backgroundColor
    2. 更改按钮的textColor

    现在,您可以为所有按钮创建一个通用的@IBAction,并使用按钮的sender 参数,您可以检查选择了哪个UIButton

    @IBAction func buttonTapped(_ sender:UIButton) {
    
       if let textOnButton = sender.titleLabel?.text {
    
          switch textOnButton {
    
            case "First": 
                 // Highlight the First button by changing the backgroundColor and textColor of the button
                 // Write logic for first button here
    
            case "Second": 
                 // Highlight the Second button by changing the backgroundColor and textColor of the button
                 // Write logic for Second button here
    
            default:
                break
          }
    
       }
    }
    

    或者你可以用同样的方式使用UISegmentedControl

    【讨论】:

      猜你喜欢
      • 2014-06-13
      • 2018-10-21
      • 1970-01-01
      • 1970-01-01
      • 2012-12-15
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 2016-07-09
      相关资源
      最近更新 更多