How can I hook up my UISegmentedControl's value changed method programmatically. I know 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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With