uipangesturerecognizer

Changing superview breaks UIPanGestureRecognizer

徘徊边缘 提交于 2019-12-05 12:11:41
I'm trying to implement a UIView that can be dragged out of its superview. I tried adding a UIPanGestureRecognizer to the view I want to be able to drag. It seems, however, that removing the UIView from its superview and adding it to another view, is breaking the gesture recognizer. With the code within the UIGestureRecognizerStateBegan commented out, the code within the other two blocks functions correctly, but when I reinstate it, the UIGestureRecognizerStateChanged and UIGestureRecognizerStateEnded states are never achieved. What is going wrong? if ([gr state] ==

Drag and Drop Image from UICollectionView to UIView?

老子叫甜甜 提交于 2019-12-05 06:04:29
Is it possible to drag an image from a collectionViewCell into a UIView? I am creating a game where the user can pick a number of items to play with in the next VC. I'm representing each item as an image and the user can select each item by dragging the image to bottom of the screen. The image would then be reset to its original location. If I have the UICollectionView functions in my code, with the image selected in a class of UIViewCollectionView all set up correctly... What do I need to include to move the image from top half (within CollectionView) to bottom half (within UIView). func

How to rotate a SCNSphere using a pan gesture recognizer

*爱你&永不变心* 提交于 2019-12-05 02:18:01
问题 I created an SCNSphere so now it looks like a planet kind of. This is exactly what I want. My next goal is to allow users to rotate the sphere using a pan gesture recognizer. They are allowed to rotate it around the X or Y axis. I was just wondering how I can do that. This is what I have so far. origin = sceneView.frame.origin node.geometry = SCNSphere(radius: 1) node.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "world.jpg") let panGestureRecognizer = UIPanGestureRecognizer

Continuous scrolling between UIPanGestureRecognizer and re-enabled UIScrollView

一曲冷凌霜 提交于 2019-12-05 00:52:52
I've got a UIScrollView with paging enabled, and I've added my own UIPanGestureRegonizer to it. Under certain instances, my view controller will set scrollview.scrollEnabled = NO , and then add the pan gesture recognizer to it (I'm not using the scrollview's own recognizer). So, scrolling is disabled but I'm waiting for user touches from my gesture recognizer. When it recognizes, it calls its action in which I re-enable scrolling. The problem is, while the user still has a finger down, my scrollview doesn't track with the finger. It doesn't start scrolling until the finger is lifted and then

Is there any priority condition between gesture methods (Pan Gesture and Swipe Gesture)?

。_饼干妹妹 提交于 2019-12-05 00:50:07
I am developing an application where I have used the Pan Gesture as well as Swipe Gesture. So every time I do the Swipe Gesture but the method from the Pan Gesture is always getting called and Swipe Gesture method is not getting called. Is there any priority between all the gesture method? You can call them in parallel by implementing the following method of the UIGestureRecognizerDelegate protocol: - (BOOL)gestureRecognizer:(UIPanGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UISwipeGestureRecognizer *)otherGestureRecognizer { return YES; } picciano

Disabling Pan Gesture if out of bounds detected

自作多情 提交于 2019-12-05 00:05:02
问题 I have a UIView I am trying to move up and down the screen, however I only wish to enable it to pan so that you cannot drag the view down when it is in its normal position (0, 0) I tried to detect when the recognizer's center is not half the height of the view, however the view is then immovable, and the center is always half the height (230 in this case). Any ideas? - (IBAction)panDetected:(UIPanGestureRecognizer *)recognizer { CGPoint translation = [recognizer translationInView:self.view];

I've made UIPanGestureRecognizer only detect mostly vertical pans, how do I make it only detect REALLY vertical pans?

谁说胖子不能爱 提交于 2019-12-04 20:15:28
I just implemented this: - (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)panGestureRecognizer { CGPoint translation = [panGestureRecognizer translationInView:someView]; return fabs(translation.y) > fabs(translation.x); } (As outlined here .) But if the user pans vertically just over the diagonal it will start. How do I make the tolerance much more strict for what it considers vertical? Basically, the image below describes what I'm after. The first diagram is what it detects now, anything within that area, and the second is what I want it to do. Rob You can use atan2f given x and

Horizontal scrolling UIScrollView with vertical pan gesture

…衆ロ難τιáo~ 提交于 2019-12-04 19:29:36
问题 I am attempting to implement a UIScrollView where horizontally panning scrolls through pictures in the scrollview but vertically panning performs another action I have. Right now I have a UIScrollView that is paginated with vertical scrolling disabled that works just fine for scrolling through pictures, but am going crazy trying to find a way to intercept vertical pans and call my own method instead of the vertical pans just being eaten up by the scrollview. I was able to do

Using multiple UIGestureRecognizers simultaneously like UIRotationGestureRecognizer & UIPanGestureRecognizer in Swift 3

无人久伴 提交于 2019-12-04 19:19:29
In modern user interfaces on iOS, it is often useful to implement multiple UIGestureRecognizers on a single view, in order to provide more realistic behavior of displayed objects that model the real world. For example, you might want to be able to both drag a view around the screen, but also use two fingers to rotate it. The UIGestureRecognizerDelegate provides an optional function shouldRecognizeSimultaneouslyWith for this purpose. Returning true avoids only one gesture having effect at a time: // MARK: - UIGestureRecognizerDelegate extension GestureController: UIGestureRecognizerDelegate {

Slowly panning in UIPercentDrivenInteractiveTransition results in glitch

穿精又带淫゛_ 提交于 2019-12-04 10:01:54
In my app I'm dismissing a viewController using a UIPercentDrivenInteractiveTransition triggered by a pan gesture. I'm expecting my viewController to be dragged to the right as I'm panning it. However when I slowly pan I get a glitch: the viewController quickly jumps from left to right a bit. This can be seen here: https://youtu.be/3IEtId1w7jM Here's the code for the transition : class FilterHideTransition: UIPercentDrivenInteractiveTransition { let viewController: FilterViewController var enabled = false private let panGesture = UIPanGestureRecognizer() private let tapGesture =