uipangesturerecognizer

ios UIPanGestureRecognizer pointer position

孤街浪徒 提交于 2019-12-03 11:06:31
问题 UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)]; [self addGestureRecognizer:panRecognizer]; - (void)pan:(UIPanGestureRecognizer *)gesture { NSLog(@"%f", [gesture translationInView:self].x); } The above code will log the relative position of my current pan, but how can I get the absolute position for the view I'm in? I'm simply just wanting to slide a UIImageView to wherever the user's finger is. 回答1: translationInView gives

UIPanGestureRecognizer limit to coordinates

别来无恙 提交于 2019-12-03 07:50:40
问题 I added to my main UIView a subview (called panel ) and i added gestureRecognizer to it because i want it to be draggable only for the Y axis and only for certain limits (i.e. 160, 300, over 300 it can't go). I implemented the gesture handling that way - (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer { CGPoint translation = [recognizer translationInView:self.view]; recognizer.view.center = CGPointMake(self.view.frame.size.width/2, recognizer.view.center.y + translation.y);

How to stop UIPanGestureRecognizer when object moved to certain frame

情到浓时终转凉″ 提交于 2019-12-03 05:19:53
I have an object of image type which I am moving using UIPanGestureRecognizer, and I need to stop recognizing the UIPanGestureRecognizer when the object reaches a certain frame. UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)]; [panRecognizer setMinimumNumberOfTouches:1]; [panRecognizer setMaximumNumberOfTouches:1]; [panRecognizer setDelegate:self]; [templatePhotoPlaceholderView addGestureRecognizer:panRecognizer]; -(void)move:(UIPanGestureRecognizer *)gestureRecognizer { CGPoint translatedPoint = [gestureRecognizer

Tinder-Like Swipe Animation for iOS

醉酒当歌 提交于 2019-12-03 03:42:33
I've followed this very helpful tutorial on how to add tinder-like swiping ( http://guti.in/articles/creating-tinder-like-animations/ ); however, I have one problem- when the picture goes away, I want to replace it with another picture. How/where do I do that? I built a simpler and more comprehensive project based on that tutorial. In particular, you could use an array of images and assign each card an image based on the index of the image. Will the images be dynamic or static? Might not help at this point, but here it is anyway: https://github.com/cwRichardKim/TinderSimpleSwipeCards check

Pan gesture interferes with scroll

泪湿孤枕 提交于 2019-12-03 00:50:31
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, is like the home screen; you can swipe left or right, but also swipe down to get spotlight. I want this

Full swipe UITableViewCell to delete UITableView iOS 8

折月煮酒 提交于 2019-12-02 22:37:08
I'd like to mimic the swipe to delete function of a UITableViewCell just like the mail app in iOS 8. I'm not referring to swipe to reveal a delete button. I'm referring to when you swipe, it discoloses 3 actions, but if you keep swiping to the left, the email is deleted. In iOS 8, UITableView has a new method where you can provide the data to display any number of buttons: #ifdef __IPHONE_8_0 - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewRowAction *viewStackRowAction = [UITableViewRowAction rowActionWithStyle

Making a slide up view similar to the new Google Maps iOS app, troubles with multiple UIPanGestureRecognizer

耗尽温柔 提交于 2019-12-02 20:55:54
I am trying to reproduce the behaviour of the slide up menu of the new iOS Google Maps application. So basically it's a view that you can slide up with panning up to a certain point or slide down to a certain point. This view can also with sliding to the right and to the left like a paginated scroll view. It should either scroll up and down or slide to the side but not both at the same time. After a lot of research and testing I have something that's close but not quite working like need it to. My implementation is a UIScrollView with a frame of 320x400 and content view of 960x400 with

Prevent UIScrollView's UIPanGestureRecognizer from blocking UIScreenEdgePanGestureRecognizer

与世无争的帅哥 提交于 2019-12-02 19:28:09
I have a UIScrollView that fills the screen on one page of my app, but I want to allow the user to pan from the edge of the screen to reveal a view behind it. The problem is that the UIScrollView steals the touches from my UIScreenEdgePanGestureRecognizer at the edge of the screen. Unfortunately, I can't access the UIScreenEdgePanGestureRecognizer from the view controller that has the UIScrollView (and vice-versa), so I am not able to use the method requireGestureRecognizerToFail: because I cannot able to specify which gesture recognizer should be allowed to fail. The view controller with the

UIPanGestureRecognizer to pop UIViewController

丶灬走出姿态 提交于 2019-12-02 18:20:38
问题 I'm wondering if it is actually possible to use a UIPanGestureRecognizer on a pushed UIViewController to achieve a similar behaviour like in the Telegram messenger chat view (and a lot of other popular Apps), where you can simply swipe to the right from anywhere on the screen to get back to the menu (or any other View Controller that initially pushed the one we are looking at). I tried this code: @objc func swipeLeft(_ sender: UIPanGestureRecognizer) { let point = sender.translation(in: view)

How to implement multiple PanGestures (Draggable views)?

北城余情 提交于 2019-12-02 08:44:24
I want to have several objects that I can drag and drop. Here's my code for moving one object (with lot of help from @vacawama): import UIKit class ViewController: UIViewController { @IBOutlet weak var panView: UIView! @IBOutlet weak var panViewCenterX: NSLayoutConstraint! @IBOutlet weak var panViewCenterY: NSLayoutConstraint! let panRec = UIPanGestureRecognizer() override func viewDidLoad() { super.viewDidLoad() panRec.addTarget(self, action: "draggedView:") panView.addGestureRecognizer(panRec) // Do any additional setup after loading the view, typically from a nib. } func draggedView(sender