iPhone touch events for any control - iphone

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?

Related

UIScrollView Pinch ZoomIn/out at certain location

I want to make application like Solar Wether application. Please see this video.
I don't want code but want to know how can we achieve functionality like zoom in/out in this application.
Please suggest me how to do this. I had made some code and done some R&D work and found this solution but want to do exact animation like this app.
You can subclass UIScrollView and use all the touch events like touchesended,touchesbegan, touchesmoved.
If you want a specific location of that touch you can get the point where the touch happens and call your custom action.

How to replicate the CNN iOS app pull down menu

Does anyone know how CNN is doing their top pull down menu?
It looks like a UITableView that is called with a touch drag event but wasn't sure. Googled various keywords but was not able to turn anything up. Just looking for some guidance on how to replicate this behavior.
I've no idea how it's actually done, but I know how I would do it: any view can sit completely or partially offscreen and be dragged onscreen by the user in the usual ways (e.g. a swipe or pan gesture recognizer). There's nothing special about that.
I guess they are doing something like https://github.com/mikefrederick/MFSideMenu
You have to customize "MFSideMenu" a lot though. If you dont want to show this menu on every view you need to disable UIGestureRecognizerDelegate on that view.
There is also something like https://www.cocoacontrols.com/controls/pullableview but you may need to add UIGestureRecognizer to this class.

How Can You Stop iOS PinchGesture from Selecting Buttons?

I'm currently writing an iOS application for the iPhone with one particular feature that creates a flowchart on the fly. The flowchart that is created is one enormous, scrollable view. Each information node of the flowchart contains buttons that automatically moves the view to the next information node. At any point in time, a user can use a pinch gesture to zoom out of the current information node and see the flowchart in its entirety.
My problem is this: I notice that if a user begins this pinch motion with one of their fingers tapping one of the buttons in an information node then this gesture takes precedence and the next node is shown as opposed the pinch gesture zooming out from the current node.
I've been looking on StackOverflow and have tried several things to fix this, but nothing yet has seemed to work. I was wondering if anyone has had similar issues and if they were able to overcome the issue?
Using #Till's advice and looking into my issue a bit more, I've done something that's worked for me and I thought I would share it here in case anyone else had similar issues or desires.
I was able to create UIViews that I could use to act as semi-buttons. For each of these views, I greated UITapGestureRecognizers and targeted them towards methods that would check to see if the sender's state is StateEnded:
-(void)handleButtonTap:(UITapGestureRecognizer *)sender
{
if(sender.state == UIGestureRecognizerStateEnded)
// Go on and do the code here
}
However, wanting to still maintain the look of the original iOS Buttons I did one step further. For each UIButton that I created, I did not associate a target with these buttons and instead created UIViews for each button. These UIViews were completely blank with a background color of "Clear." In this manner, I can now have my buttons, but still get the functionality I desired.
I hope this helps anyone else with similar issues. Thanks again to #Till for the advice.

Creating a tableview in the form of a 'film strip'

I am developing an RSS-reader-type application. I am toying with the possibility of using a normal TableView application but showing the articles as a film-strip. I am mainly thinking for an iPad application (but possible it works on the smaller iPhone as well).
The idea is to have the cells passing/scrolling across the screen using swipe touches (but horizontal, and not vertical as with the normal TableView). They will be some-kind of miniatures of the full article, and when tapped (or with multi-touch zoom to have better control) can be enlarged to read. Then can then just be be moved on as soon as the user has seen enough of it.
Does anybody know if there is an easy way of accomplishing something like that?
The most obvious solution that springs to mind would be to use a UIScrollView, as this will provide the inertial effects, etc. for free - all you'd have to do it populate it with the relevant sub-views. (UITableView's actually use a UIScrollView.)
For more information and sample code, see Apple's UIScrollView docs.
If you want horizontal scrolling, take a look at Jeremy Tregunna’s JScrollingRow. It’s open source under a public domain licence.

iPhone UISlider with two thumbs/indicators?

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.