swift - 分段控制不会切换到第二个容器

标签 swift containers uisegmentedcontrol

我的代码适用于两个容器 View ,但是当我运行模拟器时,第一个 View 显示,当我尝试使用分段控件时,我的程序崩溃并返回消息

Unrecognized selector sent to instance

我的代码如下:

@IBOutlet weak var segmentedControl: UISegmentedControl!
@IBOutlet weak var firstView: UIView!
@IBOutlet weak var secondView: UIView!
@IBAction func segmentChanged(_ sender: UISegmentedControl) {
    switch segmentedControl.selectedSegmentIndex{
    case 0:
        //show info view
        firstView.isHidden = false
        secondView.isHidden = true
    case 1:
        //show list of service view
        firstView.isHidden = true
        secondView.isHidden = false
    default:
        break;
    }

}

最佳答案

socket 可能有问题,或者您没有将方法segmentChanged正确连接到segmentControll。供您引用,请检查此链接https://www.ioscreator.com/tutorials/segmented-control-tutorial-ios8-swift

关于swift - 分段控制不会切换到第二个容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45407674/

相关文章:

docker - 构建 docker 容器时 Kubernetes 上的 Jenkins 出现问题

ios - 分段 Controller 隐藏段 0

ios - 为什么 NSDateFormatter 在给定空字符串 (""时不返回 nil )

ios - 如何从编程的 uibutton 传递数据信息到函数?

hadoop - Tez 容器是在 YARN 容器内部运行,还是代替 YARN 容器运行?

c++ - C++中的类成为容器的条件是什么?

swift - 如何在 xCode 和 Swift 中用 xyz "forced cast"修复 "only unwraps and bridges"

ios - 在不解雇 parent 的情况下,Swift 可以通过模态显示模态吗?

iphone - 在 Controller 之间传递 UISegmentedControl 值...

iOS : Custom UISegmentedControl does not adjust when orientation is changed