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.
Related
I am trying to created a vertical menu (on the left side of the screen) which I can display and hide using a gesture recognizer.
I have found a post similar to this which helped slightly, but all it did was rotate the UIToolBar to a vertical position without changing the width or position.
If anyone has succesfully created something similar to this and is willing to help I would greatly appreciate it!
Also, if anyone can point me in the right direction possibly to some sample code I would like that as well.
You could do this with a UIToolBar by applying a 90 degree rotation transform, and then having all your icons rotated 90 degrees to match - you can change the width and position simply by adjusting the UIToolBar frame. However, you will need to create your own toolbar to do this rather than using the built-in one you get with a navigation controller.
Another option is simply to roll it yourself: this will allow you more customisation, so is perhaps the better option. There are a number of third-party implementations of varying types, some based off the current Facebook App side-bar, a good place to start looking is http://cocoacontrols.com - they are of varying quality.
On the other hand, it wouldn't be too difficult to roll your own, so that's a good option to consider.
I was thinking of make a slider/joystick but not in a circle but in a line. So I made the image drag able only over the X axis and when it gets to the point where the slider stops i did this :
if(slider.center.x <= 60) {
slider.center = CGPointMake(60, slider.center.y);
}
so it wouldn't get bigger than 60 but i was thinking isn't there a better way to do this? like make a box and setting up something to not drag it outside that box?
Thanks!
I think this method is very good. As far as I know there is no wan to stop dragging in other ways than this.
However there is a control called UISlider. This control does the functionality you would like to have.
You could also use touchesBegan, touchesMoved, and touchesEnded, then add an image behind and detect when touch is less than half image's width (Left) or when it's greater than half (Right)
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 have a graphic that is 3 times the width of an iphone landscape view.
I am trying to auto scroll it so that it appears that it is moving sideways, without using the touchscreen scrolling method.
My aim is to maybe have a button you can press and it moves it left or right across the screen like an animation.
I can deal with everything else but am having trouble finding a solution.
Any example code would be appreciated or even any info on whether it is possible or not.
Thanks. Dave
You can wrap a UIView in an animation block. The animation sweeps the origin value in its frame property from one point to another, over a set period of time.
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.