uipangesturerecognizer

swapping images using pan gesture

爱⌒轻易说出口 提交于 2019-12-04 05:35:55
问题 I have multiple UIImageView added into the main view, each UIImageView is displayed in its own parent UIView for cropping purpose, each UIImageView is also attached to a PanGestureRecognizer . I am curious on how to implement both pan gesturerecgonizer and also allow image swap by dragging one image (A) to hover over the other image (B) and hold, then the image A and B will be swapped (so A is now displayed in old B's UIView). This is something like the iPhoto app just implemented. Any ideas?

How to programmatically send a pangesture in swift

走远了吗. 提交于 2019-12-04 02:24:25
I have a view that has panGesture functionality, but I need to send a pan-gesture from one point to another programatically. Is there a way to do this in swift using an animation with a specific time interval? Here is my attempt at calling the pan gesture programmatically: var upPanPoint = CGPoint(x: contentView.center.x, y: contentView.center.y + 500) var upPan = panGestureRecognizer.setTranslation(upPanPoint, inView: self) onSwipe(upPan) here is the code that recognizes the pan gesture: func onSwipe(panGestureRecognizer : UIPanGestureRecognizer!) { let view = panGestureRecognizer.view! print

How to rotate a SCNSphere using a pan gesture recognizer

我与影子孤独终老i 提交于 2019-12-03 20:13:51
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(target: self, action: #selector(CategoryViewController.panGlobe(sender:))) sceneView.addGestureRecognizer

Handling scroll views with (custom, interactive) view controller presentation and dismissal

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 18:52:04
问题 I have been experimenting with custom interactive view controller presentation and dismissal (using a combination of UIPresentationController , UIPercentDrivenInteractiveTransition , UIViewControllerAnimatedTransitioning , and UIViewControllerTransitioningDelegate ) and have mostly gotten things working well for my needs. However, there is one common scenario that I've yet to find addressed in any of the tutorials or documentation that I've read, leading me to the following question: ... What

Disabling Pan Gesture if out of bounds detected

江枫思渺然 提交于 2019-12-03 15:53:11
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]; NSLog(@"\ncenter.y: %f\ntranslation.y: %f\n", recognizer.view.center.y, translation.y); if (recognizer

Hand off parent container's pan gesture to nested UICollectionView

萝らか妹 提交于 2019-12-03 15:53:01
I'm trying to build a complex split view container controller that facilitates two variable height containers, each with their own nested view controller. There's a global pan gesture on the parent controller that allows the user to drag anywhere in the view container and slide the "divider" between views up and down. It also has some intelligent position threshold detection logic that will expand either view (or reset the divider position): This works fine. There's also a lot of code to construct this, which I'm happy to share, but I don't think it's relevant, so I'll omit it for the time

Horizontal scrolling UIScrollView with vertical pan gesture

十年热恋 提交于 2019-12-03 13:12:56
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 UIPanGestureRecognizer *panUp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)]

How to get current touch point and previous touch point in UIPanGestureRecognizer method?

本小妞迷上赌 提交于 2019-12-03 12:41:26
I am new to iOS, I am using UIPanGestureRecognizer in my project. In which I have a requirement to get current touch point and previous touch point when I am dragging the view. I am struggling to get these two points. If I use touchesBegan method Instead of using UIPanGestureRecognizer , I could get these two points by the following code: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ CGPoint touchPoint = [[touches anyObject] locationInView:self]; CGPoint previous=[[touches anyObject]previousLocationInView:self]; } I need to get these two points in UIPanGestureRecognizer

why is there a delay when moving object using UIPanGestureRecognizer

喜夏-厌秋 提交于 2019-12-03 12:19:27
问题 I'm moving UIView object using UIPanGestureRecognizer - how much I drag my finger on screen, that much I move the view in the same direction (only in X - left or right, Y is not changing). It works fine, but with (very noticeable) delay. Here is the method that handles the UIPanGestureRecognizer event: -(void)movePages:(UIPanGestureRecognizer *)sender { if(switchingMode == 1){ if([sender state] == UIGestureRecognizerStateBegan){ fingerStartPosition = [sender locationInView:self.view].x;

Pan gesture interferes with scroll

社会主义新天地 提交于 2019-12-03 11:19:49
问题 I have three view controllers that are part of a UIScrollView. I want to be able to swipe between the three, although one of the view controllers has a UIPanGestureRecognizer. I use this pan gesture recognizer to allow the user to drag their finger up and down to increase and decrease the height of a rectangular UIView. Therefore, this UIPanGestureRecognizer only really needs to know about the upwards/downwards panning, and the scroll view can use the horizontal panning. An example of this,