Lets say my UISegmentedControl has 8 numbered segments. I would like for the user to be able to turn on 2, 3, or more of them at once. Toggling them. Essentially like a bits in a byte. Is this possible? I believe it is on regular Mac OS X but I can't seem to find a way to do it in the iPhone SDK.
If I have to simulate this by putting buttons into a view, is there any way to do the following:
A segmented control is a linear set of two or more segments, each of which functions as a button. Within a segmented control, all segments are usually equal in width. Like buttons, segments can contain text or images. Segments can also have text labels beneath them (or beneath the control as a whole).
January 23, 2019. A segmented control is a set of two or more segments, each of which functions as a mutually exclusive button. Within the control, all segments are equal in width.
Segment control can be defined as the horizontal control, which controls multiple segments where a discrete button controls each segment. A segment control can be used to display multiple views within a single view controller, where each view can be displayed by using a discrete button.
Update: The custom control I mentioned here no longer works under iOS 13.
This is the best custom control I've found that allows multiple segments to be selected concurrently:
https://github.com/yonat/MultiSelectSegmentedControl
This one is a subclass of UISegmentedControl, which is convenient. I've forked it here:
https://github.com/stewartmacdonald/MultiSelectSegmentedControl
and added some code examples to the ReadMe and added a method that allows you to get an NSArray of the titles of all selected segments.
This isn't possible using UIKit. I would recommend creating a custom control, or an array of UISwitch
controls, representing each of the options in your UISegmentedControl.
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