touchesbegan

-(void)touchesBegan (TO A SPECIFIED UIIMAGEVIEW)

微笑、不失礼 提交于 2019-12-12 05:48:52
问题 Hi I want to make it so that if you touch an image that I put on the view the -(void)checkcollision happens. The -(void)checkcollision happens, but when I touch anything. How can I say it only works if i touch a specified image. e.g. a pimple: IBOutlet UIImageView *pimple; @property (nonatomic, retain) UIImageView *pimple; here is the touchesBegan code -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *myTouch = [[event allTouches] anyObject]; [self checkcollision]; }

Spritekit rotate a node while touching

扶醉桌前 提交于 2019-12-12 01:49:01
问题 I'm currently working on some sort of top down racer if you will. The idea is to have two buttons, each for turning a car left or right. This all works, but it only works with one touch. I'd like to have the player turn the car by simply holding down the button. I now have -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { /* Called when a touch begins */ for (UITouch *touch in touches) { touched = YES; CGPoint location = [touch locationInNode:self]; SKNode *node = [self

How to know when the button is pressed and canceled Button pressing

大城市里の小女人 提交于 2019-12-11 08:26:43
问题 I made a button. And used the below code. But it doesn't work at all. override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) { print("pressTest") btnConvert.isHidden = true } How can I know when the button is pressed and when button pressing is canceled? 回答1: Use the built-in UIButton functions - .touchDown , .touchUpInside , .touchUpOutside . Touch begin: myButton.addTarget(target, action: action, for: .touchDown) Touch ends: myButton.addTarget(target, action:

Touch detection doesn't work on simulator for iOS 9

北城以北 提交于 2019-12-11 03:34:00
问题 I've updated Xcode to Xcode 7. Then my Swift project to Swift 2. At last I removed removed all warnings. First scene display few SKLabel and few SKSpriteNode . Using iOS Simulator, touch detection doesn't work under iOS 9 but is ok on iOS 8. A breakpoint put on touchesBegan method show this method is not called. override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { // Breakpoint is set here } EDIT Removing these messages does not solve anything. Console display

iPad Landscape messing up touches began

て烟熏妆下的殇ゞ 提交于 2019-12-10 21:52:14
问题 My app is only allowable in the landscape orientations, and it launches in landscape. Thus, the top left corner when the iPad is landscape is (0,0), so everything works fine. However, when I pick up "touchesBegan"...it isn't working properly. Only when I tap on like the right two-thirds of the iPad does it pick up the touches. I know it has something to do with the orientation, because the app is literally just blank screen with a single UIView and nothing else. It is quite simple. There are

Draggable UIView stops posting touchesBegan after being added to UIScrollView

ぐ巨炮叔叔 提交于 2019-12-10 07:52:57
问题 In Xcode 5.1 I have created a simple test app for iPhone: The structure is: scrollView -> contentView -> imageView -> image 1000 x 1000 on the top. And on the bottom of the single view app I have seven draggable custom UIView s. The dragging is implemented in Tile.m with touchesXXXX methods. My problem is: once I add a draggable tile to the contentView in my ViewController.m file - I can not drag it anymore: - (void) handleTileMoved:(NSNotification*)notification { Tile* tile = (Tile*

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

心不动则不痛 提交于 2019-12-09 00:55:10
问题 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

iOS: Why touchesBegan has some delay in some specific area in UIView

一笑奈何 提交于 2019-12-08 18:53:16
问题 I'm making an custom keyboard and I'm in a really weird situation. I've noticed that when I catch the event touchesBegan at the rear left (about 20 pixels) of the UIView (inputView), I'll have some delay in here. Any action I do in touchesBegan will be perform slower than other area. override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { self.keypop.hidden = false } override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { { self.keypop.hidden =

Push Viewcontroller from within other ViewControllers that are not on top of Navstack?

a 夏天 提交于 2019-12-08 04:34:37
问题 i have a scrollview loaded into my mainview (with pagecontrol). What i want to do is to have the scrollview use the "Touchesbegan" method to look for double taps and then have it push a new viewcontroller onto the navstack. The second goal seems impossible. I have the seperated scrollviewcontroller call a method in the mainviewcontroller. That method should push a new viewcontroller onto the stack. It doesnt, but when i call this method from within the mainviewcontrollerclass it does work?!

SKSpriteNode erratic swipe?

一笑奈何 提交于 2019-12-06 11:39:00
I have created the following sprite kit node : SKSpriteNode *megadeth; megadeth = [SKSpriteNode spriteNodeWithImageNamed:@"megadeth_rocks.png"]; megadeth.name = @"awesome"; and added the swipe gesture as follows: -(void)didMoveToView:(SKView *)view{ UISwipeGestureRecognizer *recognizerUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeUp:)]; recognizerUp.direction = UISwipeGestureRecognizerDirectionUp; [[self view] addGestureRecognizer:recognizerUp]; UISwipeGestureRecognizer *recognizerDn = [[UISwipeGestureRecognizer alloc] initWithTarget:self action: