uitouch

How to connect two buttons( dots) with a line in iOS? [duplicate]

♀尐吖头ヾ 提交于 2020-01-13 05:35:09
问题 This question already has answers here : draw line between two points in iphone? (3 answers) Closed 6 years ago . I want to make a project in which I have to touch one dot and connect it with another dot and after connect it to another dot. When I connect one dot with another dot the line will create between them. Actually when I click/ touch one dot The line will show and When I touch second dot the line will create between the two dots. I am not able to do this yet, I am trying and

Touch and drag a UIButton around, but don't trigger it when releasing the finger

别等时光非礼了梦想. 提交于 2020-01-12 05:55:08
问题 I'm trying to allow some UIButton instances on one of my views to be touched and dragged around the screen (eventually with momentum, but that's for later!). I have this working in a very simple form, shown below, but the problem is that by touching the button to begin dragging it, it attaches to the finger, and by lifting the finger off, the "Touch Up Inside" event is triggered, which is the code I want to execute when actually tapping the button. In a nutshell: how do I differentiate

How to cancel a sequence of UITouch events?

痴心易碎 提交于 2020-01-10 02:28:47
问题 I have a UIImage view that responds to touch events. I want to cancel the touch sequence, i.e., further calls to touchesMoved: , if the touch goes outside of certain bounds. How can I do that? I know that in touchesMoved: I can inspect the coordinates of the touch object and ignore it, but what I don't know is how to cancel the sequence altogether. I don't see any method documented in the Apple Developer UIResponder Reference that I can call to cancel a touch sequence. 回答1: This solution may

Is there a pointer for each touch point in ios

不羁岁月 提交于 2020-01-05 09:35:19
问题 I have been researching everywhere and can't find if there is a unique identifier for each touch point in ios. I also would like to know how to access that in swift but can't find any documentation on it. 回答1: Not really for each point, but for each touch. To access them requires your own touch handling, for example in the UIView where the touches occur or its ViewController. This simply requires you to write your own methods for touchesBegan:withEvent: , touchesMoved:withEvent: and

How to call a method only once during -(void)touchesMoved?

霸气de小男生 提交于 2019-12-31 04:09:07
问题 I am using - (void) touchesMoved to do stuff when ever I enter a specific frame, in this case the area of a button. My problem is, I only want it to do stuff when I enter the frame - not when I am moving my finger inside the frame. Does anyone know how I can call my methods only once while I am inside the frame, and still allow me to call it once again if I re-enter it in the same touchMove. Thank you. -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event

UIControlEventTouchDragExit triggers when 100 pixels away from UIButton

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-28 03:50:10
问题 At present, the UIControlEventTouchDragExit only triggers when I drag 100 pixels away from the button. I'd like to customize this behavior and bring that range in to around 25 pixels, but I'm relatively new to programming and have never needed to override / customize an in-built method like this. I've read in some other posts here that I'd need to subclass the UIButton (or perhaps even UIControl ?), and override -(BOOL) beginTrackingWithTouch: (UITouch *) touch withEvent: (UIEvent *) event

UIView do not react on Apple Pencil

╄→гoц情女王★ 提交于 2019-12-25 04:34:21
问题 In my app some of UIView s don't react on Apple Pencil. When I make touch by finger, all works fine. I supposed that this might be caused by adding new property type in iOS 9. And I tried to change the type of touches: touch.type = UITouchTypeDirect; But this is readonly property. Does exist any way to make equal touch by finger and touch by Apple Pencil? How do I make my app react on Apple Pencil? 回答1: UITouch class determines whether the touch is made by a stylus or by a finger, as stylus

iOS do not forward touches to views below

左心房为你撑大大i 提交于 2019-12-25 04:09:35
问题 In my app I have UIScrollView which has many UITableViews. In cells of this table there is UISlider. How I can disable touch forwarding if user make scroll gesture on table view? Now if user make scroll gesture near slider (but not on it) the touch event gets forwarder to scroll view. 回答1: You can subclass UIScrollView and add this method to the new class - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *result = [super hitTest:point withEvent:event] ; self.scrollEnabled

Drawing straight line with spritekit and UITouch creates multiple lines

拈花ヽ惹草 提交于 2019-12-25 03:07:55
问题 Should be simple. I'm trying to draw a single, straight line using UITouch and Spritekit. However, when touchesmoved is called, it creates multiple lines instead of just a single line. Code used is below: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; positionInScene1 = [touch locationInNode:self]; pathToDraw = CGPathCreateMutable(); selectorLine = [SKShapeNode node]; selectorLine.strokeColor = [SKColor greenColor]; selectorLine

event.touchesForView().AnyObject() not working in Xcode 6.3

ぐ巨炮叔叔 提交于 2019-12-23 21:12:42
问题 This worked perfectly before: func doSomethingOnDrag(sender: UIButton, event: UIEvent) { let touch = event.touchesForView(sender).AnyObject() as UITouch let location = touch.locationInView(sender) } But in Xcode 6.3, I now get the error: Cannot invoke 'AnyObject' with no arguments How do I fix this? 回答1: In 1.2, touchesForView now returns a native Swift Set rather than an NSSet , and Set doesn't have an anyObject() method. It does have a first method, which is much the same thing. Note, also,