restrict my touch area to part of UIImageVIew - ios5

I have a UIViewController into which i added a UIImageView with CGRectMake(0,0,1024,704). (768-nav bar ht-status bar ht=704). I am working in landscape mode only. I added tap gesture to this UIImageView. But i want to restrict this tap area to the height to 604. This picture should make it a bit clear.
The area with red lines is the UIImageView and the are that has green and red lines is the area that does not need touch event.
Any idea how to go about doing this?

You can use the locationInView: method in UITabGestureRecognizer to know where the user tapped, and respond accordingly.

Related

iPhone - How to partially hide the subview?

I am developing one sample application using gestures, where i can pinch, pan and rotate. I have one main image view width and height is 300 and origin x is 0 and y is 70. This imageview I am using from interface builder. After this i am adding one label programmatically on the middle of the imageView. After adding the label I can able to pan, pinch and rotate the label on the view. Now the actual requirement is when i drag the label outside the imageview I should be display the partial label, for example (My label text is ABCDXYZ). As soon as I drag the Z outside the Z should be invisible, other part ABCDXY should be visible. More clear is drag the one view inside other view. How can i achieve this.
What you have to do is create a UIView. On that add the UIImageView like
[View addSubView:ImageView];
then add the UIlabel on the UIImageView like
[ImageView addSubView:Label];
Now set the clipsToBounds = YES. I think now your issue of the partial label would be solved as the label would move within the UIView and as soon as it goes out it would be shown partially. Any doubt please tell . Thanx :)
Its really tricky to give handheld solution for this, instead it could be a suggestion. I assuming that your UILabel text is dynamic, there's some scenarios you can follow to achieve this.
1) When you touch your label inside UIImageView you shoud get the exact coordinates of it.
2) Get the position where user touch on UILabel.
3) Compare the touch coordinates with total coordinates of UILabel.
4) Assume which character did touched. (You should make test of it, also text size may also matters).
5) When user drag that particular character (say Z) you need to remove that from UILabel text.
That's all. You're done.

UIImageView Tap Gesture Sensitivity

I have an ImageView object on my screen. When I tap it, it displays an info in a bubble style view. The problem is the imageview is very thin and small, it does not pick the tap gesture. Any suggestions about how to increase the sensitivity? Any solutions?
You need to increase the size of the screen area that is responding to the tap. So you could make the imge view bigger (but set the content mode to center so the image isn't stretched).

User Interaction Enable in a UIImageView under another UIImage View

I have two UIImageView in a UIView in my application. And I need to Zoom, Rotate and Move the UIImageView which is at bottom of the top one, I don't need to do any thing with top one. I've already implemented the code for Move, Rotate and Zoom but the problem is I cant enable the touch to UIImageview in bottom.
How to solve this problem?
UIImageView's have userInteractionEnabled set to NO by default. You have to explicitly set this to YES for the image view you want to allow touch events to occur on.

How to blink a touch area in UILabel iPhone?

I have an UILabel. I want to glow the touch area in it. That is, when I click on a point in that UILabel, a small circular portion around the touch point should be presented with glowing effect. How can get this?
Well you can do that by creating a CALayer or a CAGradientLayer based on how you want your glow and add it as a sublayer to the label's layer at the location of the touch.
For enabling the touch on UILabel, look at userInteractionEnabled property. You will need to set it to YES.
Then you will need to attach a UITapGestureRecognizer to the label for getting the tap. Once you have the touch location, add the custom glow layer as a subview to the label's layer in an invisible state. Animate the glow layer in and out. You might want to repeat a few times before removing the glow layer as a sublayer at completion.
UILabels don't respond to touches.
Use a UIButton with a custom type and provide images for the normal state and the (glowing) highlighted state.
Gesture recognizers are nice, but if you want to do something that starts when the finger touches, stops when the finger stops touching, and moves around with the finger in between, then it's hard to think of a good gesture recognizer for that. I think in that case you'd be better off just using touchesBegan, touchesMoved, and touchesEnded (don't forget touchesCancelled).
You can either put those methods on your view controller or subclass UILabel. Either way, set userInteractionEnabled = YES on the label.
As for how to graphically make that effect, I don't have any clever ideas for it at the moment.

Iphone Custom Scrollview indicator

I am currently working on an application for a client, and they have made an odd request. The request involves putting a custom image as the indicator for the scrollview. I am not even sure if this is possible but if it is can you please let me know how one would go about doing that.
Thanks
UIScrollView streches a small, semi-transparent circle image to generate its scrollbars. You can find this image as the first subview of a UIScrollView:
UIImageView *circle = [scrollView.subviews objectAtIndex:0];
However, as I said this image is stretched, and as far as I can tell, only the alpha values are considered when drawing the scroll bars.
So for example if you're only interested in changing the top/bottom ends of the scroll bar, you can try to change this image. However, I doubt you'll be able to do anything interesting.
A possible solution that comes to mind, and this is only a theory, is to add a custom, transparent UIView on top of a UIScrollView. Then you can hide the default scroll bar (by using showsHorizontalScrollIndicator and showsVerticalScrollIndicator), pass the necessary touch events to the UIScrollView to scroll the content, and draw the scrollbars in your custom view.