I have a UIScrollView with a zoomed image view contained within it. UIScrollView "contentSize" is about twice the height of the scrollview itself, enabling user to swipe the image up and down. What I'm seeing is that the "touch zone" for the UIScrollView (where it detects swiping, and scrolls the image accordingly) is only at the very bottom of the UIScrollView. Is there any property/method I can use to make the UIScrollView detect swipes throughout it's frame?
if you want touch points inside scrollview tgen you can use following delegate method-
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
Related
There are countless questions about UIScrollViews, touch events and subviews, but I couldn't find one that solved my dilemma. I have a UIScrollView with delayed and cancellable content touches in which I have added UIButtons. I can scroll the view wherever I touch (including the buttons), but if my finger lingers on a button for too long, it registers as touching the button, as I want and is expected. However, if I then move my finger as if trying to scroll, the scroll view does not scroll - how can I make it do so? The basic effect I am trying to achieve is like a UITableView handles touches for the cells.
Thanks for your help.
Try implementing the following in your UIScrollView subclass:
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
return YES;
}
I put one UIImageview as subview in a UIScrollview. When I zoom in the image, I can scroll the image around. Can I disable the scrolling when I touch and moving in a rectangle area of the image?
I want to get information from touchesBegan() of customed UIScrollview and customed UIImageview, but I found that when there are scrolling, no touchesBegan is called in customed UIImageview.
yourScrollView.scrollEnabled = YES; for scroll to be enabled.
yourScrollView.scrollEnabled = NO; for scroll to be disabled.
I am stuck with a problem actually the scene is like this in my view controller i have place several buttons which i can move within the view now in same view half of the screens is occupied by uiscrollview in this scrollview also i have several uibuttons which i want to move from uiscrollview to uiview Now when i try to move uibutton from uiscrollview to uiview it hides as it moves from the scrollview similarly as i move uibutton from uiview to uiscrollview then also it hides as my drag reaches the scrollview area.
Please help me out with this problem
Thanks in advance....
Your UIButtons each have a superview. For the UIButtons in the scrollview, the UIScrollView is the superview. When you have scrollView.clipsToBounds == YES, then the UIButtons in the scrollview will become obscured if you move them outside of the visible area of the scrollview.
There are several possible solutions, including:
Add code to change the superview of the UIButtons once they reach the edge of the scrollview (but this is tricky, and I wouldn't do it unless there was an easier option, check out Apple's UIView documentation, especially (UIView)removeFromSuperview and (UIView)addSubview:). You would have to perform this switch of superview in the code that moves the button (or tracks the move).
Add the UIButtons to a UIView which is the parent of the scrollview, maybe even your viewcontroller.view (but your UIButtons in the scrollview will no longer move with the scrollview upon scrolling). You would add the buttons to the view behind the scrollview, but so that they show above it.
I have displaying image thumbnails in a UIScrollView, if user taps on a thumbnail, the application should open that image. if, however, user drags on a thumb, the scroll view should pan. Right now the scrollview only scrolls if user is able to drag on the small empty space between the thumbnails. the subviews (the one's displaying image thumbs) use a UITapGestureRecognizer to detect taps, and exclusiveTouch on subviews is set to NO, UIScrollView has its canCancelContentTouches set to false.
Try leaving canCancelContentTouches set to YES, that allows the scroll view to override its subviews if it seems the user is trying to scroll.
I have two UIImageView objects inside my view (both 320x480 one above the other). The lower image view is inside a UIScrollView with scrolling and zooming enabled. Now I want to handle touches inside the other image view but it no longer detects any single taps.
I can understand that the UIScrollView handles all the touches which I do on it. But the touches on the image view above the scroll view are also not recognized.
Attached is an image with my view hierarchy. Can someone please tell me why the other image view's touches are also handled by the scrollview when it isn't a subview of scroll view?
And if the scrollview is bent on handling touches, how do I recognize touches on the other image view?
Thanks.
By default UIImageViews have userInteractionEnabled=NO;
Try setting it to YES (either in IB or in code).
I'm not sure, it might be that you need to set the frame size and/or content size of the scroll view properly. This page has a diagram of what I'm talking about.