I created custom UIScrollView and add UIImageView.
I want to detect horizontal swipe gesture on the UIScrollView, but I cannot do it.
I cannot find any other references in my case.
I found only following url, but it's not real detecting gesture.
How to recognize swipe gesture in UIScrollView
I've not any zoom effect.
Please help me.
Doesn't one of the UIScrollViewDelegate methods such as [UIScrollViewDelegate scrollViewDidScroll:] work for you? I don't know your specific case, but standard way of detecting swipe action in UIScrollView should be through its delegate.
Related
I have UIImageview as a subview of UIScrollview, I can zoom in or out by using this
tutorial http://cocoadevblog.heroku.com/iphone-tutorial-uiimage-with-zooming-tapping-rotation, the problem is how can I detect swipe gesture when I zoom UIScrollview in,
I know how to implement swipe gesture, and it work normally except when I zoom UIScrollview in.
Thank you very much for your time.
have a look at following links,hope it helps ..
How to implement zooming *and* paging like iOS Photos app
How to implement Swipe Gesture for UIImageView randomizer
What gesture recogniser should I use if I want to the user to swipe between 2 UIView's in the same way they swipe between photos in the Photo app? No the zooming just the transition between 2 photos.
Should I use the swipe or the pan gesture?
I am also using this with the UIPageControl so that when they swipe the page changes and the new view is visible.
The answer is you use no gesture recogniser, instead you have to implement your own dragging method in scroll view delegate methods. Look at Apple's code they have written for this; http://developer.apple.com/library/ios/samplecode/PageControl/PageControl.zip
I think It would be better to use swipe gesture recognizer.I have used same way with UIPagecontrol and its working smoothly.
I have an atypical iOS interface. Perhaps it's not practical but I'm giving it a go. Hope someone can help!
I have a menu in the form of a UIVIew. It contains 5 small UIImageViews. A UIPinchGestureRecognizer is attached to the UIVIew. When pinched inward, the 5 UIImageViews animate from off screen to form a circle in the middle of the window. When pinched outward, they animate back offscreen. Everything works great there.
I'd like to be able to, at any point in the application, pinch the screen to reveal the menu, select one of the 'buttons' (UIImageView), and load the associated subview.
The real problem is, if the current visible view is a UIScrollView or UITableView, my app is having trouble figuring out whether the menu or other subview should handle the touch event. If I really focus and make sure two finger touch the screen at the EXACT same time, the pinch will work and pull the menu inward. But otherwise, it attempts to scroll the current visible view.
I would like all events except the pinch gesture, (and a tap gesture when the menu is visible), to pass through the menu view to the rest of the subviews.
I understand I can override the hitTest:withEvent method to determine the correct view to handle the event, but I'm unclear at this point how exactly to use it. Neither the Apple docs nor any answers I've read on stack overflow have made this method clear to me.
Any help is much appreciated.
As UITableView is a subclass of UIScrollView, it inherits all of UIScrollView's properties including its gesture recognisers.
UIScrollView declares a UIPinchGestureRecognizer and UIPanGestureRecognizer. I'm not sure of the implementation details but I imagine the UITableView disables the pinch gesture recogniser as you are not supposed to be able to zoom a tableview!
In any case, you can attach your own UIPinchGestureRecognizer to the table view:
UIPinchGestureRecognizer *yPGR = [[UIPinchGestureRecognizer alloc]
initWithTarget:probablySelf action:yourMenuShowSelectorHere];
UITableView *tv = ...
// ...
[tv addGestureRecognizer:yPGR];
Then, you can make sure that the UITableView scoll does NOT scroll until your pinch has failed:
[tv.panGestureRecognizer requireGestureRecognizerToFail:yPGR];
This way, the UITableView will not scroll until it is sure that it has not detected a pinch.
EDIT: UIScrollView only uses (or at least declares public access to) UIGestureRecognizers in iOS 5 and up.
I've been trying to create a UITextView subclass that handles swiping away the keyboard like in the Message.app.
I have a UIPanGestureRecognizer added to the keyWindow of my app, and the gesture delegate is configured for shouldRecognizeSimultaneouslyWithGestureRecognizer. Everything works fine except for when the UIScrollView is decelerating, during that phase it is possible to pan without the touches being registered.
You can take a look at a very simple github sample project here.
I have tried adding the UIPanGestureRecognizer directly to the viewController.view and to the scrollView, same issue occurs. I have also tried setting scrollView.panGestureRecognizer requireGestureRecognizerToFail: with my UITextView subclass gesture recognizer.
Any ideas as to why this may be happening?
Instead of creating a new UIPanGestureRecognizer, maybe you could use the one on the UIScrollView, and add your own pan logic to that gesture recognizer with - (void)addTarget:(id)target action:(SEL)action.
I have a UIScrollView and an UIImageView as its subview. I want to draw on the imageview in response to the single touches. And I want to zoom and pan the image view in the scroll view on pinch and pan gestures respectively. I found many solutions. But its not perfect. Please give me a straight forward solution.
use after subclassing UIScrollview.See the link.If you are doing application for iphone4 OS,try to use UIGestureRecogniser.see the sample code for it in Apple site.
If you are only using the scrollview for panning and zooming, I would suggest subclassing UIImageView to provide that functionality yourself along with the drawing. This will allow you to have finer control over it and quicker code. A scrollview is not very good at allowing complex gestures within it. (other than taps)