touchesbegan

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

Moving multiple nodes at once from touch with SpriteKit

老子叫甜甜 提交于 2019-12-02 09:16:12
问题 I have a game that has 3 SKSpriteNodes that the user can move around using the touchesBegan and touchesMoved . However, when the users moves nodeA and passes another node called nodeB , nodeB follows nodeA and so on. I created an array of SKSpriteNodes and used a for-loop to make life easier. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let nodes = [nodeA, nodeB, nodeC] for touch in touches { let location = touch.location(in: self) for node in nodes { if node!

Moving multiple nodes at once from touch with SpriteKit

不打扰是莪最后的温柔 提交于 2019-12-02 06:51:12
I have a game that has 3 SKSpriteNodes that the user can move around using the touchesBegan and touchesMoved . However, when the users moves nodeA and passes another node called nodeB , nodeB follows nodeA and so on. I created an array of SKSpriteNodes and used a for-loop to make life easier. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let nodes = [nodeA, nodeB, nodeC] for touch in touches { let location = touch.location(in: self) for node in nodes { if node!.contains(location) { node!.position = location } } } } Everything is working except when nodeA is moving

touchesBegan not called in a UIView subclass

假如想象 提交于 2019-12-02 00:00:48
问题 I am trying to mimic the GLPaint app and I have a TDPaintingView that has methods for -(void)touchesBegan... as well touchesMoved , touchesEnded , and touchesCanceled . However, I am not seeing any of them fire. I have a TDAppDelegate that is hooked up to a Window in IB and a TDPaintingView in IB. The initWithCoder method for my TDPaintingView definitely fires, so I know it is being initialized. Furthermore, I can see from logging the object TDPaintingView from the context of

touchesBegan not called in a UIView subclass

ぐ巨炮叔叔 提交于 2019-12-01 20:50:02
I am trying to mimic the GLPaint app and I have a TDPaintingView that has methods for -(void)touchesBegan... as well touchesMoved , touchesEnded , and touchesCanceled . However, I am not seeing any of them fire. I have a TDAppDelegate that is hooked up to a Window in IB and a TDPaintingView in IB. The initWithCoder method for my TDPaintingView definitely fires, so I know it is being initialized. Furthermore, I can see from logging the object TDPaintingView from the context of applicationDidFinishLaunching that it is definitely there. When I change the view in trivial ways in IB (making bg red

touchesBegan not called in UIView subclass

感情迁移 提交于 2019-12-01 15:58:21
I know there already are some questions about this but I couldn't find a solution. There is a very simple code that works just fine on one of my projects but not on an another one: Here is the code for subclass of UIView. import UIKit class test : UIView { init(frame: CGRect, color: UIColor) { super.init(frame: frame) self.backgroundColor = color self.userInteractionEnabled = true } required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { super.touchesBegan(touches, withEvent:

Touchesbegan not detecting what is being touched

喜夏-厌秋 提交于 2019-12-01 11:32:18
I'm building a rotating banner using a NSTimer to keep track of the current image with the image being animated from 5 different images. I have a touchesBegan set up to keep handle the touch event on the banner if someone clicks it. My proof-of-concept works, but moving it into another project, it breaks. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; if ([touch view] == myImageView){ [self getImage]; NSLog(@"%@", currentImage); } } Now when I put break points into my project, it grabs the touch just fine, but when it gets to

Touchesbegan not detecting what is being touched

旧街凉风 提交于 2019-12-01 08:30:53
问题 I'm building a rotating banner using a NSTimer to keep track of the current image with the image being animated from 5 different images. I have a touchesBegan set up to keep handle the touch event on the banner if someone clicks it. My proof-of-concept works, but moving it into another project, it breaks. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; if ([touch view] == myImageView){ [self getImage]; NSLog(@"%@", currentImage

touchesBegan method not called in UITableViewController class in iPhone

痴心易碎 提交于 2019-12-01 02:22:52
How can I use touchesBegan: withEvent: method in UITableViewController class? UITableViewController is a subclass of UIViewController class. So why the method does not works in UITableViewController? touchesBegan is a also UIView method besides being a UIViewController method. to override it you need to subclass UIView or UITableView and not the controllers. I had a similar problem, and found a different approach that doesn't involve subclassing UITableView. Another way to do this is to add a gesture recognizer to the UITableViewController's view. I put this code in the UITableViewController's

`touchesBegan:withEvent:` is delayed at left edge of screen

五迷三道 提交于 2019-11-30 22:47:11
I'm experiencing an issue where the first call to touchesBegan:withEvent: on a UIView or UIViewController is delayed when you touch on the left edge of the screen. This seems to be a new issue with iOS 10, and only happens on devices with 3D Touch (iPhone 6s and newer). In fact, if you disable 3D Touch in General->Accessibility, the issue goes away. However, the issue doesn't seem to happen when you use UIGestureRecognizers . My workaround at the moment is to create a UIGestureRecognizer subclass that overrides the touches* methods and forwards them to my old implementation. Is this just a bug