开发者

UISegmentedControl value changed programmatically

开发者 https://www.devze.com 2023-03-20 17:52 出处:网络
How can I hook up my UISegmentedControl\'s value changed method programmatically. I 开发者_如何学Goknow it\'s possible using IB but I was wondering how to do it with code. Thanks.Attach a target-actio

How can I hook up my UISegmentedControl's value changed method programmatically. I 开发者_如何学Goknow it's possible using IB but I was wondering how to do it with code. Thanks.


Attach a target-action for the control event UIControlEventValueChanged.

Example

[segmentedControl addTarget:self action:@selector(valueChanged:) forControlEvents: UIControlEventValueChanged];


You can use the addTarget:action:forControlEvents method.

UISegmentControl *mySegmentedControl = [UISegmentControl ...];
[mySegmentedControl addTarget:self action:@selector(segmentValueChanged:) forControlEvents:UIControlEventValueChanged];
0

精彩评论

暂无评论...
验证码 换一张
取 消