uipangesturerecognizer

Swipe to delete on CollectionView

↘锁芯ラ 提交于 2019-12-01 02:11:37
I'm trying to replicate the swipe to delete function like in the mail tableview. Only this time I need to build it on a collectionview but I'm having a bit of a hard time. It's a horizontal scrolling list with a swipe up to delete. I already got the swipe up working but having a hard time figuring out how I need to setup the swipe to delete / tap to delete or ignore functionality. It looks like the following: So I'm using the following collectionview: func buildCollectionView() { let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal layout

Making use of velocityInView with UIPanGestureRecognizer

血红的双手。 提交于 2019-12-01 00:07:10
I have a custom slider-type object, that I wish to make more usable. Currently I use UIPanGestureRecognizer and translationInView to make it work. It works pretty well but I'd like some sort of velocity in there to make it feel a bit more useful. I've tried a few things but cant quite figure out how to properly implement velocity changedLevel equation. - (void)panDetected:(UIPanGestureRecognizer *)gesture { CGPoint swipeLocation = [gesture locationInView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:swipeLocation]; LevelCounterTableCell *swipedCell =

Swipe to delete on CollectionView

∥☆過路亽.° 提交于 2019-11-30 21:36:08
问题 I'm trying to replicate the swipe to delete function like in the mail tableview. Only this time I need to build it on a collectionview but I'm having a bit of a hard time. It's a horizontal scrolling list with a swipe up to delete. I already got the swipe up working but having a hard time figuring out how I need to setup the swipe to delete / tap to delete or ignore functionality. It looks like the following: So I'm using the following collectionview: func buildCollectionView() { let layout:

How to restrict a moveable view by Pan gesture

北战南征 提交于 2019-11-30 20:22:36
I have a UIImageView which is moveable via a pan gesture. UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; [self.photoMask addGestureRecognizer:pan]; I would like to restrict the area this can be moved on screen. Rather than the user be able to drag the view right to the side of the screen, I want to restrict it by a margin of some sort. How can I do this? Also, how is this then handled when rotated? EDIT --- #pragma mark - Gesture Recognizer -(void)handlePan:(UIPanGestureRecognizer *)gesture { NSLog(@"Pan Gesture"); gesture.view

Making use of velocityInView with UIPanGestureRecognizer

二次信任 提交于 2019-11-30 18:31:05
问题 I have a custom slider-type object, that I wish to make more usable. Currently I use UIPanGestureRecognizer and translationInView to make it work. It works pretty well but I'd like some sort of velocity in there to make it feel a bit more useful. I've tried a few things but cant quite figure out how to properly implement velocity changedLevel equation. - (void)panDetected:(UIPanGestureRecognizer *)gesture { CGPoint swipeLocation = [gesture locationInView:self.tableView]; NSIndexPath

Use UIPanGestureRecognizer to drag UIView inside limited area

独自空忆成欢 提交于 2019-11-30 16:26:33
I want to allow user to drag UIView inside a limited area of its super view. Trying the following simple code: func handlePanForImage(recognizer: UIPanGestureRecognizer) { if let myView = recognizer.view { switch (recognizer.state) { case .Changed: let translation = recognizer.translationInView(self) if insideDraggableArea(myView.center) { myView.center = CGPoint(x:recognizer.view!.center.x + translation.x, y:recognizer.view!.center.y + translation.y) recognizer.setTranslation(CGPointZero, inView: self) } default: break } } } I see that indeed the view is not dragged outside the limited area,

UIPanGestureRecognizer do something immediately when touched

戏子无情 提交于 2019-11-30 11:44:22
I am new to ios, so I apologize in advance if I am missing something obvious. I am creating a puzzle where I would like the individual puzzle pieces to increase in size on touch and decrease on letting go. Currently I have: -(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer{ if(recognizer.state == UIGestureRecognizerStateBegan) else if(recognizer.state == UIGestureRecognizerStateEnded) } The puzzle piece increases size when the pan begins (which is also when the statebegan) and decreases in size when the pan ends (as expected). I would like the size to increase once the user has touched

How to determine true end velocity of pan gesture?

一个人想着一个人 提交于 2019-11-30 05:53:32
When using UIPanGestureRecognizer and detecting UIGestureRecognizerStateEnded , then the velocity of the gesture is not the true velocity. Instead, it's the old velocity of the previous invocation of my action method. How can I access the true velocity at the end of the gesture? I create my UIPanGestureRecognizer like this: UIPanGestureRecognizer* panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognized:)]; [panGestureRecognizer setMaximumNumberOfTouches:2]; [panGestureRecognizer setMinimumNumberOfTouches:1]; [panGestureRecognizer

How to make a collectionview respond to pan gestures outside of it's own view

谁都会走 提交于 2019-11-29 23:16:49
问题 I've got a UICollectionView in my UIViewController and I want it to respond to gestures inside AND outside of the UICollectionView . By default the UICollectionView only responds to the gestures inside its own view but how can I make it respond to swipes outside of its view ? Thanks. 回答1: I wrote a view subclass that accomplishes just this: #import <UIKit/UIKit.h> @interface TouchForwardingView : UIView @property (nonatomic, weak) IBOutlet UIResponder *forwardingTarget; - (instancetype

How to limit pan gesture area?

只谈情不闲聊 提交于 2019-11-29 22:18:45
问题 I am having my UIImageView onto which I am having another UIView rectangle. By applying pan gesture to UIView rectangle it gets outside of UIImageView also. I don't want to be drag outside of UIImageView I have tried below code but it is not working that way -(void)handleMovementView:(UIPanGestureRecognizer *)recognizer { CGPoint movement; if(recognizer.state == UIGestureRecognizerStateBegan || recognizer.state == UIGestureRecognizerStateChanged || recognizer.state ==