In my app for iPhone/iPad (in Objective-C), there are some UiButton's and other events and an UiImageView. Image covers the whole screen and i want that when one touches the upper or bottom area of screen(means suppose one button in the upper area), then the image resizes to a specific size.
But i am not able to recognize if one touches the upper area or not, like in the Photo Gallery of the iPhone(where if i touches the upper/lower area the navigation button appears, the same thing I want in my app).
I already have the touch events in my app:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
If somebody has any idea or solution please let me know.
The most obvious solution would be to subclass the UIImageView, then override it's touchesBegun:withEvent: method and in that method check where the actual touch happened:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch * touch = (UITouch *)[touches anyObject];
CGPoint location = [touch locationInView:self];
if (location.y > some_arbitrary_value || location.y < some_other_arbitrary_value)
{
//touched upper or lower part
}
}