[英]How to create IBAction from UISegmentControl?
這與按鈕操作相同,唯一的區別是您應該使用“ ValueChanged ”,而不是選擇TouchUpInside或其他按鈕事件
UISegmentControll將響應值更改操作
在您的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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.