tayhalla / thsegmentedcontrol Goto Github PK
View Code? Open in Web Editor NEWMultiple Selection Varient of UISegmentedControl
License: MIT License
Multiple Selection Varient of UISegmentedControl
License: MIT License
I'm using THSegmentedControl inside a tableviewcell. When a button is pressed in another cell, I reload the tableview and want to deselect or select all of the segments. When I try to call setSelectedIndexes
with:
[_scheduleCell.segmentedControl setSelectedIndexes:[[NSOrderedSet alloc] initWithArray:@[]]];
nothing happens.
Thanks for putting this control together! I've got it working in my project, but I can't figure out how to select certain segments programatically..
With a UISegmentedControl, I can select one segment as follows:
self.segmentedControl.selectedSegmentIndex = someDefaultIndex
I have a control with 7 segments (representing the days of the week), and by default, I want 5 of them to be enabled (representing workdays).
Is this possible with THSegmentedControl?
If not, I'm open to trying to add this support to THSegmentedControl: Any idea which file I'd need to modify to do so?
All the best,
Andrew Ash
I realize you haven't touched this code in 5 years, but thought I would log this bug anyway.
In clearExistingSeperatorsAndLabels, you go through the self.segmentLabels to remove them from their superview so that you can create new ones every time the control is re-drawn, but the problem is that the segments are never added to self.segmentLabels, so it's always empty. This results in a new set of segments being added as subviews on every redraw.
Hi,
first of all let me thank you for your good work. =)
Unfortunately I'm not able to unselect all segment graphically. Passing in nil or an empty NSSet does the right job under the hood but does not update the controller visually.
Calling setNeedsDisplay manually does not help either. At the moment I'm removing and re-adding the controller when I need this done.
Thank in advance. โ๏ธ
No THSegmentedControl.h and THSegmentedControl.m in the project.
- (void)commonInit
{
// Init
self.backgroundColor = [UIColor clearColor];
self.clipsToBounds = YES;
self.preSelected = NO;
// Textfield init
self.textField = [[THLabel alloc] initWithFrame:self.bounds];
self.textField.backgroundColor = [UIColor clearColor];
self.textField.tintColor = self.segmentHighlightedBackgroundColor;
self.textField.clipsToBounds = YES;
self.textField.adjustsFontSizeToFitWidth = YES;
self.textField.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.textField];
}
tintColor
is only available from iOS7 so this crashes iOS6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.