[英]How to change only text color when UISegmentedControl value changed?
[英]UISegmentedControl value changed programmatically
如何以编程方式连接我的 UISegmentedControl 的值更改方法。 我知道使用 IB 是可能的,但我想知道如何使用代码来做到这一点。 谢谢。
为控件事件UIControlEventValueChanged
附加一个目标操作。
例子
[segmentedControl addTarget:self action:@selector(valueChanged:) forControlEvents: UIControlEventValueChanged];
您可以使用 addTarget:action:forControlEvents 方法。
UISegmentControl *mySegmentedControl = [UISegmentControl ...];
[mySegmentedControl addTarget:self action:@selector(segmentValueChanged:) forControlEvents:UIControlEventValueChanged];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.