Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get string value from UISegmentedControl

How can I get the text value of a segment in a UISegmentedControl?

like image 588
Matt S. Avatar asked Mar 22 '10 01:03

Matt S.


2 Answers

Objective-C

NSString *title = [segment titleForSegmentAtIndex:segment.selectedSegmentIndex];

Swift:

let title = segment.titleForSegment(at: segment.selectedSegmentIndex)
like image 114
Kevin Sylvestre Avatar answered Nov 16 '22 19:11

Kevin Sylvestre


[segmentedControl titleForSegmentAtIndex:int];

For the current selected index

[segmentedControl titleForSegmentAtIndex:[segmentedControl selectedSegmentIndex]];
like image 31
Brandon Bodnar Avatar answered Nov 16 '22 18:11

Brandon Bodnar