I need to rotate an image when the user do a two finger twist on it.
do you have an idea on how i can code this or if you've done this before.
I think it would be a good idea to write a class that detect all the main gesture and provide iif.
I found this example on the internet. It's very nicely written...
http://www.skylarcantu.com/blog/2009/08/08/multitouchsingletouchtap-handling/
When you rotate your thumb and index clockwise what really happens is that:
the thumb starts on the right
descrives a u shape underneath the index
finishes on the left
If you look at the full gesture it is .) rotated clockwise. In some cases, the index will move slightly south-east so you get /).
I suggest looking into SDK 3.2 - it has extended support for gesture detection.
Related
I am working on a sample in which I have placed two textures one above the other. What I want, whenever user moves his finger on the screen, underneath view should get revealed as he moves. Wiping out front view to reveal underneath view is what I am looking for.
I would like to know some of ideas/ thoughts to implement this feature using OpenGL ES. Any related pointer will be highly appreciated.
Thanks in advance.
This does not sound performance-intensive so simple code can trump complicated tuned operations.
You don't need to use OpenGL. You can simply have two images - front and back - with the front supporting an alpha channel. Each time you get a hit or move, you clear a circular patch whereever the impact is for some certain radius or such.
And then queue-up a redraw. The redraw draws the two bitmaps, back first then front.
If possible, try to queue a redraw for just the the area where you have updated the front since the last draw.
I want to create a 360 degree turntable showing lots of pictures (12, 24 or 36) by controlling that rotation with touch events (like that example but coded for an iOS app natively).
The simplest idea depending on the touch position is to load that specific uiimage.
Any ideas what's the best practice for that? Is there a chance to create that image-turntable with the help of coreanimation faster? Any other hints on that? Any other projects known where I can get some help on that?
Thanks for your time and hints in the right direction.
Here's another example for an ipad-app from the "audi a8".
From the first example it becomes obvious that the objects have actually been photographed for each angle of rotation. This is the really tricky part. You will need a tripod and a camera with remote control, and if possible also a rotational platter to keep angles consistent.
Implementation is relatively straightforward. As you guessed, you just track the touch positions and, depending on delta to the last touch position, show the appropriate image.
well, you can just use the HTML/CSS/JS used in the same example... just load that in an UIWebView in your app and load your site embedded as a resource...
Subclass UIImageView, load array of your frames, handle tap movement over the screen y-axis and change active image accordingly. Don't forget to loop your images. :)
I am trying to implement a volume-control-like round button. Currently I can detect swipes by the Gesture Recognizer. How can I detect a circular gesture (clockwise and anti-clockwise) on the button? Thanks!
Are you looking for a one-touch gesture (like a circular slider), or a two-touch gesture (like grabbing and turning a real-world knob)? If the latter, take a look at UIRotationGestureRecognizer.
If the former, you're pretty much on your own. You can certainly implement your solution as your own custom gesture recognizer: this is expected by Apple, and there's some documentation to get you started (though I haven't seen many working examples out there). See also How to correctly subclass UIGestureRecognizer.
As a general approach, I'd think of the region for the gesture as a donut shape: a zone with center c, inner radius r1, and outer radius r2. When the user touches down you can calculate the distance from c using the Pythagorean theorem, and the angle with your favorite trig function. With that, you can determine whether the touch is within the zone. As the user drags, you can update the control value based on the angle. At some point, they'll either touch up, or drag outside of the zone, and that will end the gesture. I suggest allowing the touch to stray pretty far inside r1 or outside of r2: fingers are imprecise tools.
As failing to find a solution, and by logical inspiration from #sixten's answer, I've gone and created something useful, it's not bullet proof, but it seems to do what I need for now.
Please anyone, fork it, clone it, use it, improve it, it's open source, here's my repo link:
https://bitbucket.org/danielphillips/dpcirculargesturerecognizer
Have you tried writing your own gesture recognizer? There are detailed instructions in the docs.
Best Way would be implement Custom Gesture Recognizer. I do not know if you wish to detect a Discreet Gesture (Event Handling method would be called once the full circle has been detected) or a Continues Gesture (Event Handling method would be called every time you move your finger on a circular Path).
Probably, the user may not draw a perfect circle, and the solution provided by #Sixten Otto would be good.
I am trying to design another app and am struggling to think of the best way to do it. I'm after some advice please!
If you imaging a bicycle wheel in the middle of the ipad (and iPhone)... I want the user to be able to click on the tyre and spin it to the left or right. Depending on the speed of the swish will drive the speed of the wheel rotation.
It should rotate around the centre of the wheel and not move any other direction.
Do I need to use some graphics code, or simply listen for the touch, check the area they touched, then rotate the image around it's centre left or right?
Really I'm after some pointers around the methods to use - I'm not being lazy and asking for code, but if anyone knows of tutorials - that would help immensely!!
Thanks for any info.
Your best bet is to use one of the UIGestureRecognizer subclasses, probably UIPanGestureRecognizer as it includes velocity.
Apple's SimpleGestureRecognizers project will help you get started.
I'm using UISwipeGestureRecognizer successfully to capture and action when gestures on the screen are made with single or multiple touches in Up, down left or right directions using the standard tools.
However what I really need to do now is have the device recognize diagonal swipes in the same way.
Does anyone have any ideas where to start?
Do I simply subclass UIGestureRecognizer myself and try to work out how to roll my own UIDiagonalSwipeRecognizer? Or is there a way of detecting if a swipe is, say, up && left?
Your help is appreciated...
I'd simply use an oldschool "touchesBegan" and "touchesEnded" and there check the x and y delta, if both of them is greater then some minimum constant, then this swipe should be a diagonal one.
Correct me if I wrong but UISwipeGestureRecognizer available from iOS 3.2 only, and if so that is not an advantage.