Sliding finger across multiple image views - iphone

I have dynamically created a grid of 8x8 image views over which letters are displayed and assigned the tag to each.I can detect the touch on each image view through Tap Gestures but what I want now is : if the user slide its finger across the letters, i would be able to get the each image view tag. So that the letters touched can be detected(the continuous touch).
Please Help,
Thanks In Advance.

Disable user interaction on the individual image views and handle touches on the superview containing them instead. Then you can figure out which image the user's finger is over in touchesMoved.

As the other poster said, you need to handle the touch events on the superview. You could use touchesBegan/touchesMoved, or you could add a pan gesture recognizer to the superview. Personally, I prefer gesture recognizers. I find them cleaner and easier to use, so I'd go that route.

Related

Using pan gesture recognizer to move multiple imageviews together

I'm creating an app for the iphone in xcode where the background image is much larger than the screen. I've added in a pan gesture recognizer to the imageview of the background, which allows it to be moved freely so the user can see beyond the character they control.
This is working perfectly, but when I add in additional imageviews(for the character and other objects throughout the area) they will remain stationary. Is there a way to connect multiple imageviews to a single pan gesture recognizer so that when one is moved, they all move together?
I tried connecting the other imageviews to the referencing outlet collections of the pan gesture recognizer, but when the program is run it only pans the last imageview connected, while the others remain stationary.
I'm new to xcode, and I'm sure this is something relatively simple that I'm overlooking, but I haven't been able to find an answer on the internet so any help would be appreciated. :)
Thanks!
The best way is to make the character (and other views) a subview of the backgroundImage.
Note that in the NIB (.xib) file you cannot add a Subview to UIImageView but you can do it programatically.
If you prefer working in the NIB file you can make a "container" UIView that holds the background image and other characters inside that view.
Then for the gesture recognisers you'll transform that view.

Rectangular Selection like in Windows Desktop

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.

How to drag view with two finger

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.

Looking for direction for a Custom Gesture like swipe to scroll

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.

touch multi UIViews

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).