Is anyone aware of a version of the iPhone UISlider control with two thumbs? I need a control that will allow specifying a range of values. The UISlider API docs would imply this isn't possible with the standard control, so I was wondering if anyone had a solution for this (or had solved it themselves).
Here's a range slider I just cooked up
http://github.com/cmezak/CMRangeSlider
If you're still interested this is my implementation. I'm making it well documented so everyone could start using it with ease.
https://github.com/fcy/fancy-ios/tree/master/src/ui/range-slider
It works with iOS 5+
I had this problem too. The way I solved it was a bit of a hack but simpler for noobs like me!
I put two sliders on top of eachother. Made the track of one invisible using a transparent .png file. Then created a sliderReleased: method that I linked to the touch up inside event in interface builder that switches the userInteractionEnabled: state of each slider.
It means that you can only set one slider at a time and you have to touch one before you can set the other but for my purposes it does the job.
I linked both sliders' touch up inside to this method and set tags to 1 and 2 and linked the value changed event to individual methods like normal.
-(IBAction) onReleaseBP: (id) sender {
if ([sender tag]==1) {
[diastolicSld setUserInteractionEnabled:NO];
[systolicSld setUserInteractionEnabled:YES];
}
else {
[systolicSld setUserInteractionEnabled:NO];
[diastolicSld setUserInteractionEnabled:YES];
}
I made a range slider called DoubleSlide, it's not based on UISlider. But you can add images to make it look like one:
it's in here:
https://github.com/richy486/RACommon
Here's my solution. One advantage versus other double-slider controls is that mine supports both setting up the control in code and in Interface Builder using IBDesignable/IBInspectable.
https://github.com/vermont42/JFADoubleSlider
I'm not aware of a current one (ie. still in active development) but you could probably derive one by looking at the source of BWToolkit ( http://brandonwalkin.com/bwtoolkit/ ).
There's an iTunes style slider implementation you could probably extend.
It's BSD licensed and the source is available from bitbucket.
Related
I want to make Switch, which have three states.Basically I need to store value 0 or 1 or 2.
By checking the state of Switch.
Please Help to make this switch.If it can be made Using IB that will be very nice because it will be easy to place in the right place.
(I have image but not able to show bec am new, dont have 10 reputation yet)
Thanks in advance for your creative thinking
You should use a UISegmentedControl for this. It's part of the standard set of controls, Apple has taken care of accessibility support, and users will know what to do with it.
Making a custom control that looks like UISwitch but behaves differently is a bad idea.
I am curious as to whether or not there is an open source solution to replicate the flash button in the iOS camera applicaiton.
I have seem many other apps use this, but there doesn't seem to be a native way, so I assume there is a common source out there.
It is possible to get the flash button by using UIImagePickerController class, but most of the camera apps out there don't seem to be using this (or perhaps they subclass it, which is against apple's terms).
I am looking for a way to replicate the expanding behavior of the button. Any thoughts?
It doesn't sound too hard.
The way I'd do it is to separate the right curve of the button (as images), and make a UIView that has the left part of the button and the right curve as subviews.
When it's tapped, slide the right curve and animate the extra buttons in.
You could use a stretchable UIImage (see UIImage documentation) and then just animate the frame changing.
In the Apple 2010 WWDC Sample code (downloadable via iTunes, otherwise I'd post it here), there are several sample applications which use this control. They call the class ExpandyButton. I realize I'm answering my question, but hopefully someone out there can find this useful.
While looking for a similar solution to this problem I came across this code which was extremely helpful. Similar to ExpandyButton it fit my needs better.
https://github.com/ddebin/DDExpandableButton
I'm using the core-plot library to do some plotting, and would like to implement some touch control on the graph. Problem is, the core-plot graph view doesn't seem to respond to touches. I've read many places that it's possible to place an invisible control over another control and use that control to give the underlying control touch events. Problem is, I can't figure out how to implement it. Nothing seems to be working. Is there some way to specifically assign a control your own touch events and to handle them separately from the other controls? Some source code showing how this should be set up properly would be awesome.
Just a simple question before I go to sleep (it is past midnight in Europe :)). Did you try adding subview to your graph with backgroundColor = [UIColor clearColor] and attaching a UIGestureRecognizer to it?
I'm writing an application that uses UIImagePickerController. I'd like to give users choice of source of pictures, either take a new photo or choose from existing ones. I'd like to create exactly the same selection interface as is in twitterfon or in safari when you hold tap on the link. It looks like some standard SDK thing but I have completely no clue where to find some sample code. I've googled for hours and I have nothing.
I would really appreciate any tips.
Thank you
What you're looking for is the UIActionSheet. The documentation has everything you need to set one up and how to respond to which button is pressed.
You'll also want to use the constants defined for the UIImagePickerController sources, namely
UIImagePickerControllerSourceTypeCamera
UIImagePickerControllerSourceTypePhotoLibrary
That would be an UIActionSheet. Make sure to point its delegate property to your implementation of the UIActionSheetDelegate protocol to catch clicks on the buttons you define.
I'm working on an iphone application (not web app) and I'd like to build a form asking a user to indicate a price range. Instead of using two text fields, I would prefer to use a double slider to set the minimum and the maximum price. I know that it is possible de use a simple slider (sound control for exemple) but i've never seen a double one. Can anyone help ?
This is not possible without creating a custom control. You'll need to inherit from UIControl or UIView and provide a custom drawRect method. You'll also need to respond to touch and drag events to update the state of the control. I have not done this myself, but I would be prepared for a fairly significant amount of work to get everything to respond and display as expected.
I'm curious as to why you need to have both values specified on a single slider? Why not use two sliders either side-by-side or stacked? It would not require any more input steps than a double slider, and would conform more to standard UI guidelines.
I think you can specify multiple thumbs for a single slider if you subclass UISlider, at least I vaguely remember that being possible in MacOSX. But Code Addict is right, you'll probably be better off using the standard controls - a double-thumbed slider seems like it'd be pretty difficult to deal with in the touchscreen environment.
I built such a control and added it to GitHub so feel free to have a look and if you like the control extend it and contribute.
GitHub page: http://github.com/doukasd/DoubleSlider
Blog post (showing a video of how it works): http://dev.doukasd.com/2010/08/double-slider/