I have a UIScrollView with zooming enabled. This zooming enabled scroll view is inside another UIScrollView. The outer scroll view should receive the two fingers pan/swipe to switch pages. Here is my problem, the UIScrollView can treat the two fingers pan/swipe as on finger, but if the inner scroll view enabled zooming, the pinch gesture recognizer in the inner scroll view will be very sensitive. Any tiny two fingers movement will be interpreted as a pinch gesture and it prevents the outer scroll view to receive two fingers pan. Is it possible to change the sensitivity of the pinch in UIScrollView.
I did see there is a #package variable called _scaleThreshold in UIPinchGestureRecognizer, but it is package variable and can't be accessed outside. It is impossible for me to change it.
I'm wondering whether there is a way to make the threshold larger for the pinch gesture in UIScrollView.
Thanks
You can set the scale and the velocity props of UIPinchGestureRecognizer, one of them maybe right for what you want.
EDIT: Or you could call the requireGestureRecognizerToFail:recognizerYouDontWantInterfering merhod on whatever gesture you want to take effect.
Related
I'm wanting to make a UIView which acts similar to the iOS home button action where you can swipe a UIView with a gesture upwards until it is off the screen at which point it is deleted.
Although I can achieve the ability using a standard gesture, it does not give much UX feedback and would like to clone the ability to swipe upwards and make the UIView inline with the touch.
I'm wondering how to replicate or clone this ability where you can press and swipe upwards and the UIView will move in accordance to touch and delete.
thanks
I use an UIPageViewController to pan between three views.
I want to blur the background of the third view when I pan from the second to the third view (and vice versa).
Therefore I have attached an additional UIPanGestureRecognizer to the second view.
This UIPanGestureRecognizer animates the alpha-property of an image view which contains a blurred representation of the background image from 0.0 to 1.0 as soon as the right border of the second view has passed the middle of the screen. An additional UIPanGestureRecognizer of the third view does the opposite when I pan from the third to the second view.
Unfortunately this behavior is static. The panning of the UIPageViewController is interactive.
When I want to pan from the second to the third view and the right border of the second view passes the middle of the screen, the burred image view gets visible while I'm panning. But while I'm panning I can change my mind and cancel the transition when I pan back to the original position. The blurred view stays visible although the second (and not the third) view is on screen.
Similar problems occur when I pan very fast a too short distance. The UIPageViewController will move to the third view but the blurred image view stays invisible.
Is there any way to synchronize the transition of the views with the visiblity/invisibility of the burred image view?
The UIPageViewController delegate protocol has two interesting methods:
pageViewController:willTransitionToViewControllers:
pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:
Unfortunately both methods doesn't work for my purposes.
The UIViewControllerAnimatedTransitioning feature of the iOS 7 SDK also seems not to work with the UIPageViewController.
Has anyone an idea?
Sounds like iOS7 feature UIViewControllerInteractiveTransitioning (which also encompasses the associated non-interactive animated transitioning) is indeed what you need. You might consider replacing your UIPageViewController with some other mechanism that can make use of this approach, such as UINavigationController.
How can i zoom a UIView without using UIScrollBar? I can add pinch gesture recognizer but how can i move the zoomed image to selected area?
What prevents you from using UIScrollView? It is probably the most easy way to handle zooming and scrolling.
If UIScrollView is not allowed. You can probably add pinch and pan gesture recognizer and implement their delegates for zooming and scrolling.
Please check this..
Image-manipulation-with-uigesturerecognizer
Here is Sample Project
I have a UIView within a UIScrollView. When i want to simulate the drag event on the UIView, swipe event on the UIScrollView is being triggered.
As per the documentation , there isn't much of a difference between swipe and drag.
Swipe
1- Place the pointer at the start position.
2- Hold the mouse button.
3- Move the pointer in the swipe direction and release the mouse button.
Drag
1- Place the pointer at the start position.
2- Hold down the mouse button.
3- Move the pointer in the drag direction.
On an ipad I can use two fingers two swipe and one finger to drag. Now, how do i go about doing something similar on the simulator; drag instead of a swipe?
Edit 1:
I should have been clearer first up. Anyway, my problem is that the mouse drag is firing the swipe instead of drag, thereby scrolling the scroll view instead of passing on the drag event to the UIView contained by the scroll view.
I am on macbook pro. Two-finger swipe on the touchpad is being ignored. Touch and drag is causing the same thing as mouse-drag.
Thanks
See Jeff LaMarche's quick note on how to do this. It's documented in the same page you're reading, but Jeff's explanation is clearer.
If you want to simulate a two-finger gesture in the iPhone simulator, hold down the option key. You will get two dots on the screen instead of one. The two dots will default to pinching - if you bring the dot closer to the center of the screen, the other dot comes toward the center, making it easy to simulate a pinch in or pinch out.
If you want to do a different two-finger gesture, get the two dots the distance apart that you want them to be, then hold down the shift key, while still holding down the option key. That will lock the position of the two finger presses together so you can do, for example, a two-finger swipe.
see this documentation below:
iOS Simulator User Guide
Just use the mouse to drag the view, aka, left click the view then move the mouse
I ended up disabling the scrolling from the UI and added two buttons to scroll the scroll view. Since this is a work around only for the emulator, I have used #ifndef to hide the buttons while building for the device.
I’ve got a view that has to be presented both in landscape and portrait. The transition between different orientations is done by repositioning and resizing the subviews. One of the subviews is a button (plain UIButton with an image background). When the interface rotates to landscape, the button starts misbehaving – it can only be tapped on its left part, the right part does not respond. When I move the button a bit to the left, the tappable part grows. The button should not be obscured by any other view, it’s clearly visible. When I override the hitTest:withEvent: method in the parent view, I see that the taps in the “numb” part of the button result in nil being returned. I think I have seen this behaviour once before, but unfortunately I’ve forgotten the source of the problem :) Any help?
Ah yes, I forgot to resize the view itself. Thus the button was on the boundary of the view and even though it was not clipped, the part lying outside the view frame was not considered for hit tests.