Hi all:
I want to write a gesture recognizer on the iphone, that I cold use two finger to drag the view. Just like we use two finger on the MacBook Pro's touch pad.
If the view's size is larger than the window's size of the device, I could use two finger to drag the view. is there any good way to solve it ?
(Thanks enamrik and Naveen Thunga. I achieved my goal just now, but there is a new question that how could I know the UILongPressGestureRecognizer is over. I want call a method and set some value when my finger leaves the screen of my iphone.)
The UILongPressGestureRecognizer class has a numberOfTouchesRequired property you might find useful
Use uigesturerecognizer's properties and enable View's multitouch property. See some sample on UIGestureRecognizer that may help you.
Related
I want to move a image to the right or to the left with the swipe gesture recognizer, i´m already moving the image using the CCMoveTo function, but I don´t know how move the image faster or slower depends of the force of the swipe.
If the user make a strong swipe the image should move faster than if the user make a soft swipe.
Anyone have any advice?
A UISwipeGestureRecognizer is a one shot thing. It fires when the device detects the gesture and is done after that.
If you want more information about the movement of the finger you should check UIPanGestureRecognizer.
That's what the property velocity in the UIPanGestureRecognizer is for. You can see an example of how to use it in class 08 (I think) of cs193p by Paul Hegarty. Here's the link to download it from iTunes U
I'm making a Schedule App for Cocoa Touch and I need to be able to select a time interval just by touching the screen. I mean, the user must be able to select with its fingers a time interval within the "ScheduleView" and then Add an event.
I was thinking of making some kind of rectangular selection, similar to the one that everyone can do in Windows Desktop, but i don't know how to detect multiple touches, neither how to draw the selection rectangle. Can anyone help me?
P.S: The "ScheduleView" it's a UIView, not a UITableView
You'll need to add a UIGestureRecognizer to your view. You can detect touches as a delegate, and this case will probably do best with a UIPanGestureRecognizer. You'll set the delegate to be yourself and draw the box within -(void)panGestureMoveAround:(UIPanGestureRecognizer *)gesture Here is a tutorial.
To draw the box, you could manually draw into the view but it may be easier to reshape a UIView on top and manipulate its border width and color like this SO question.
I'm trying to have a sort of gesture that will seamlessly switch between a group of images this part I have sorted. The part that is catching me up is the gesture to do so and how I might introduce acceleration.
Basically the user would swipe as normal and after the swipe is registered it would change the image displayed and the faster once swiped the faster the image would change ideally it would then keep that speed until the users finger was lifted leaving the possibility to just scroll repeatedly through the images.
Any direction someone could give me would be great.
Thanks.
Assuming you would be using a UIScrollView for this, setting the scrollView.decelerationRate property would allow you to manipulate the deceleration rate/scroll speed. To calculate the "swipe speed", take a look here: Detecting Special touch on the iphone for some pointers.
There are a series UIViews arranged very close.
alt text http://www.mobilepanda.com/questiontouch.png
I hope when my finger touches some of them, my app can detect which UIView touched.
Maybe one or two or three.(because the displayed parts of each UIView are too thin).
I hope to get the middle x value of the touch, then spread the UIView where the middle x value locates and the UIViews near it.
alt text http://www.mobilepanda.com/questiontouch1.png
My way is put a transparent UIView over all these UIView to detect the touch event.
I am not sure if this is ok? or there is any better solution.(for example, make each UIView has the capability to detect the touch, mix and decide which UIView is touched.
Welcome any comment
Thanks
interdev
You don't need to do all that. The OS will decide what the center point of the finger touch is and send an event with the touch x,y coordinates to the correct view. If you make them UIButton's (a subclass of UIView) instead of UIView's the OS will do all the work for you. All you have to do is attach callbacks to each button to the functions you want called for various events (like touchUpInside, touchDownInside, etc).
I have a view that is moving. The view is sometimes on and sometimes off screen - it is twice the width of the screen.
In this view, there are buttons that I need to be able to click.
I've tried doing this in many ways already - using pure buttons
using touches began on UIView
I'm doing the animation using a CGPath in core animation
Any help would be most appreciated
Thanks
Whether the view is moving or not should irrelevent to the touch detection. If you have a UIButton object and are handling the UIEventControlTouchUpInside (forgot the exact name) event , it should be called when it sees a touch. Is that not working for you?