我在我的项目中处理UISegmentControl
。我能够在拖放的帮助下创建 UISegmentControl
的 socket 和 socket 集合。但无法创建段控制的 IBAction
。
我想我错过了非常小的东西。知道我现在应该如何进行吗?
为了更清楚,您可以引用此屏幕截图。
最佳答案
在你的 controller
中尝试这段代码:
@IBOutlet weak var segmentedControl: UISegmentedControl!
@IBAction func segmentedControl(sender: AnyObject) {
if segmentedControl.selectedSegmentIndex == 1 {
// Do something with the first button
}
else {
// Do something with the second button, etc...
}
}
然后将它从您的code
拖到您的segmentedControl
关于ios - 如何从 UISegmentedControl 创建 IBAction?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36568548/