Custom gestures on iOS. iPad - iphone

I am looking to create my own gestures for my iPad app. I know this can be done but don't know where to start. I read that there is some sample code that can store your custom gestures so you can re use them. Think it was as ajson
I'm looking to draw numbers as custom gestures but any sample code/tutorial where I can get an idea where to start I would be very great full!
Thanks ahead.

The best place to start would be the Event Handling Guide for iOS section on Gesture Recognizers. There's a lot of information there on the different types of gesture recognizers. This should give you enough information on how to create the recognizer(s) that best fits your scenario.

Related

iphone recognize different shapes with finger movement

I'm developing an application for iPhone, and I want to detect different shapes as my fingers move on iPhone surface. Can anybody help me, how can I detect the different geometric shapes via finger movement or gesture in iPhone sdk.
You can do it, but it's not an easy task. iPhone SDK provides UIGestureRecognizer class, you may create a subclass that UIGestureRecognizer that recognizes a distinctive gesture or character (in your case).
But there is also another approaches. One of them described by Brit Gardner in his blog. Underlying this approach is the N-Dollar Recognizer based on JavaScript. This guy had done a nice job and now you can use MultistrokeGestureRecognizer-iOS library for detecting symbols and shapes. Of course, this library is not perfect and it use specific way (like JSON) to recognize touches, but it's better than nothing.
Thanks, hope this help someone.
There is a sample custom UIGestureRecognizer built inside the iOS SDK documentation which recognizes a checkmark gesture here, specifically in the section entitled "Creating Custom Gesture Recognizers" (couldn't find an easy way to directly link the section). Using this as a template, you should be able write a custom gesture recognizer to correctly recognize your gesture.
The part you will have to provide yourself is the code which defines for your device what exactly it means to make your particular shape of interest.
Incidentally, I'm also in the process of writing my own custom UIGestureRecognizer as an example of recognizing a continuous gesture as opposed to the checkmark's discrete gesture recognition as I would have appreciated an example of this previously.
It is available on Github.
Back in 2009 Daniele Margutti created MCGestureRecognizer project also based upon http://depts.washington.edu/aimgroup/proj/dollar/
If you can find this it will give you a big heads up but will likely need updating to ios5. It used to be available at http://www.malcom-mac.com but that site seems to be down.

How to use UIPinchGestureRecognizer

I have made a simple web browser for the iPhone but I would really like to be able to pinch to zoom in and out with the UIPinchGestureRecognizer, but I don't know how to use it. Could someone explain to me how to implement it in my code? If you have a link to a good explanation of this that would be very much appreciated as well.
Why do you need to implement it at all? UIWebView already supports pinch-zooming natively.
For all the stuff you need for gesture recognizer's, look here. Basically, you set up a gesture for your view, and add a selector method that would get called if the view recognizes that gesture. In this case, when it detects a pinch, you would tell the view to change size to your liking.
This, however, is the hard way of doing it though, as the pinch gesture is already associated with a UIWebView (not to mention, the MKMapView as well). You should probably look at this other post to see what you need to do. Any search on google will also point you in the right direction. Hope that helps!

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.

Implementing tracing gestures on iPhone

I'd like to create an iPhone app that supports tracing of arbitrary shapes using your finger (with accuracy detection). I have seen references to an Apple sample app called "GestureMatch" that supposedly implemented exactly that, but it was removed from the SDK at some point and I cannot find the source anywhere via Google. Does anyone know of a current official sample that demonstrates tracing like this? Or any solid suggestions on other resources to look at? I've done some iPhone programming, but not really anything with the graphics API's or custom handling of touch gestures, so I'm not sure where to start.
If you're on 3.1.3 firmware you can use the touchesBegan, touchesChanged, and touchesEnded methods. If you were to do an iPad app on 3.2, you'd have access to gesture recognizers such as UIPanGestureRecognizer - which provides the same basic functionality but also gives you some extra information.
The problem here is that they will not give you a smooth line without some extra work on your part, but these are the basic ways to handle finger tracking.
Unfortunately I don't have any examples to give you, but check out the stuff I mentioned in the developer documentation. You should be able to at least get started from that.
I'm uncertain if gesture recognizers are available in 4.0. Might be worth checking out.

Is there a high-level gestures library for iPhone development?

The iPhone platform has a number of common gesture idioms. For example, there are taps, pinches, and swipes, each with varying number of fingers. But when you're developing an app, it's up to you to implement these things based on low-level information about the number and locations of touches. It seems like this is a prime candidate for a library. You would register a delegate, set some parameters like multi-tap interval and swipe threshold, and get calls like swipeStarted/Ended, pinchStarted/Ended, multiTap, etc. Does such a library exist?
I've set up just such a project. It's not a library, but it is full of sample code for pinch/stretch, tap and hold, etc.
Blog:
http://6tringle.com/blog/2009/TouchSampleCode.html
Github:
http://github.com/kailoa/6tringle-touchsamplecode/tree/master
Here is one for detecting the circle gesture, with the source code provided. Might be useful for adapting it to detect other geatures.
http://iphonedevelopment.blogspot.com/2009/04/detecting-circle-gesture.html
UIGestureRecognizer. Don’t roll your own.
I forked Kailoa's very nice example and attempted to create a library.
http://github.com/bentford/GestureDetect
I intend to add a combination "pinch-zoom and drag" gesture like the one in the maps app. Once I get it working, I'll post on github.