Implementing tracing gestures on iPhone - 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.

Related

iOS iPhone finger paint-like app, is there a built-in canvas or open source projects to help me get started?

I need to implement on-screen drawing feature within one of my apps. I would imagine it would be an on-screen transparent overlay. I'm looking to be able to trace the finger path and leave a line, select colors and have erase/undo feature.
I did some research of what's currently on the app store, and a lot of those apps look similar and use similar brushes.
Something tells me that they look too much alike for this to be a coincidence. Does apple provide any built-in finger painting canvas, or are there some widely-known open source projects for on-screen drawing?
Thank you!
I ran into the same thing while looking for examples when I got started with drawing, so I released my efforts as a sample project called SimpleDrawing. I tried to keep things basic while supporting most/all of the standard drawing tools and operations.
There is the GLPaint project, which you can get here.
Other than that, you could use CoreGraphics & -touchesBegan:withEvent: if you wanted.

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.

Custom gestures on iOS. iPad

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.

Simulate touch on iphone

Im trying to simulate a touch on as UIWebView, how can I programmatically fire a touch event at a certain location? (x and y coordinates)
Just call touchesBegan?
Ideally I'd like to do it without any javascript hack because in the future it may not be a uiwebview
It's not easy to synthesize a touch event on the iPhone: you have to use undisclosed API, so you have a high probability of breaking on every update of the iOS and getting rejecting from Apple.
Here's a link that demonstrates how to synthesize a touch event on the iPhone:
Here's another question on StackOverflow: How to send a touch event to iPhone OS?
It's worth pointing out the KIF framework here. It's intended to run in the simulator but part of the code is simulating touch evens in code. with luck, this will be a good starting point.
https://github.com/square/KIF
Specifically, look at stepToTapViewWithAccessibilityLabel in KIFTestStep.m and the line
[view tapAtPoint:tappablePointInElement];
What you need to do is first create the events you want, and then send them to SpringBoard over the "purple port" eg. mach port. To make them system wide you must forward them to each application over the port. That means you need to actually do what the windowmanager does and looking at which app is active, screen locked, etc.
There are a hand full of private framework APIs that work (IOSurface, GraphicServices, SpringBoardServices, etc.) to get you the pieces you need.
You will have to load these private frameworks at runtime using something like dlopen().
This is 100% possible without jailbreak as of iOS 6.1.4 (current ATM), but you will be loading private frameworks which is not allowed by apple for AppStore ;)
It is possible. Exactly how you mentioned, using GSEvents and sending them to the purple named port of the aplication you are trying to control/simulate. Of course you need KennyTM's GSEvent.h to accomplish this.
I've done this for iOS 4.3, just by changing some of the values that Kenny had (like kGSHandInfoTypeTouchDown), but now I'm trying to do it for iOS 5 and it's not working, till now.
EDIT: It is now working for iOS 5.1.
Without jailbreaking there is no real way to hook a gesture recognizer into all views of the entire system. First off, your app running in the background doesn't have the ability of executing this code.

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.