Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether the UISegmentedControl is selected or not by user?

I got an app in which I allocate 5 UISegmentedControl dynamically into the view. And got a Done button at the end. My condition that to proceed into next step (when done button is pressed), all the UISegmentControls "should be selected by user".

The default selection in segmentcontrol is none. How to check whether all the UISegmentedControls in my view is selected by the user before action on the done button is executed?

like image 486
Lithu T.V Avatar asked Aug 23 '11 07:08

Lithu T.V


People also ask

How do you get the selected segment title in Swift?

Enter Swift as Language and choose Next. Go to the Storyboard and drag a Segmented Control to the top of the main view. Also drag a Label to the view and place it below the Segmented Control. Select the label and give it a text of First Segment selected.


1 Answers

Right from the apple document, this should answer your question:

@property(nonatomic) NSInteger selectedSegmentIndex

Discussion The default value is UISegmentedControlNoSegment (no segment selected) until the user touches a segment.

Hope you can use that to check whether the value is user selected or not, to prevent going to next page.

like image 73
Saran Avatar answered Sep 27 '22 21:09

Saran