touchesbegan

UIButton blocking touchesBegan and touchesMoved

◇◆丶佛笑我妖孽 提交于 2020-07-13 15:36:25
问题 I'm writing an app for tvOS - and it all works until I put a UIButton on the screen. The problem, when buttons are added, is that touchesBegan and touchesMoved stop working. If I remove the buttons then touchesBegan and touchesMoved start working correctly again. I have tried, in the interests of experimentation, unchecking 'User Interaction Enabled' - but this didn't make any difference. I have also tried subclassing UIButton and adding the following code: - (void)touchesBegan:(NSSet *

Dragging views on a scroll view: touchesBegan is received, but no touchesEnded or touchesCancelled

断了今生、忘了曾经 提交于 2020-01-22 20:42:09
问题 As an iOS programming newbie I am struggling with a word game for iPhone. The app structure is: scrollView -> contentView -> imageView -> image 1000 x 1000 (here fullscreen): I think I have finally understood how to use an UIScrollView with Auto Layout enabled in Xcode 5.1: I just specify enough constraints (dimensions 1000 x 1000 and also 0 to the parent) for the contentView and this defines the _scrollView.contentSize (I don't have to set it explicitly) - after that my game board scrolls

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

Moving SKSpriteNode to location of the touch

◇◆丶佛笑我妖孽 提交于 2020-01-11 04:15:28
问题 Above is an image of my game. A top-down game. Wherever on the screen the player touches, I want the bullets to go to that location with a duration. I also want the player to be able to drag around his finger on the screen, and the same thing happens. So that the player doesn't have to touch the screen everytime he wants to shoot. I've tried some different stuff so far but nothing seems to work. First off, I dont know if I should have a separate function for the bullet. But anyway, this is my

Custom UIView touch area

岁酱吖の 提交于 2020-01-07 05:05:26
问题 Hello I have some weird shapes that I need to handle the touchesBegan method on. The issue is that UIViews are square and the only way I could do it is to maybe declare a grid and then check the coordinates. Is there any other way of doing this? 回答1: Implement hitTest:withEvent: in your UIView subclass. Return YES only if the CGPoint is inside the shape. Check out this question for polygon shapes: How can I determine whether a 2D Point is within a Polygon? 回答2: Also, if you have access this

Referring to my view controller in another class (scene.swift) - all variables turn to null? Swift 3

喜你入骨 提交于 2020-01-04 07:54:34
问题 I am trying to call a method from my view controller in my Scene.swift class - which I am able to do. The method is called after the touchesBegan method is called when I click on an SKLabel node, which are set up in my view controller. The problem is that when I click on an SKLabelNode, control passes to the Scene.swift class and within the touchesBegan method, the method I want to call is called, so the control is passed back to the view controller, when I get back here it seems that all my

Resizable Centered Circular UIView

无人久伴 提交于 2020-01-01 19:35:14
问题 I am looking for a way to create a CIRCULAR UIView that is resizable and stays centered ( see image ). The CIRCULAR view in this example is a UIView subclass WCSDailyGoal . ContainerView.m - (void)createDailyGoalView { _dailyGoalView = [[WCSDailyGoalView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; _dailyGoalView.delegate = self; _dailyGoalView.goal = 200; _dailyGoalView.center = self.view.center; [self.view addSubview:_dailyGoalView]; } WCSDailyGoal.m - (void)setGoal:(CGFloat)goal {

Subclass UIScrollView in Swift for touches Began & touches Moved

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 12:12:01
问题 I'm using Swift 1.2 I'm trying to use this UIScrollview touchesbegan,touchesmoved,touchesended actions and the link in the 2nd comment of the accepted answer. I'm using a storyboard with auto layout, I set my custom class for the UIScrollView in Custom Class. I'm not receiving either of these touch events in the UIViewController that contains my custom UIScrollView Edit: Updated my code for how I use it with @Victor Sigler 's answer. Custom ScrollView Code: import UIKit protocol

Subclass UIScrollView in Swift for touches Began & touches Moved

强颜欢笑 提交于 2020-01-01 12:10:03
问题 I'm using Swift 1.2 I'm trying to use this UIScrollview touchesbegan,touchesmoved,touchesended actions and the link in the 2nd comment of the accepted answer. I'm using a storyboard with auto layout, I set my custom class for the UIScrollView in Custom Class. I'm not receiving either of these touch events in the UIViewController that contains my custom UIScrollView Edit: Updated my code for how I use it with @Victor Sigler 's answer. Custom ScrollView Code: import UIKit protocol

EXC_BAD_ACCESS right after touchesBegan

馋奶兔 提交于 2019-12-25 02:39:07
问题 I have started a very simple project to learn iOS programming, but I get EXC_BAD_ACCESS after touchesBegan . You can download the project from DropBox here . I basically have a UIView subclass that should draw circles wherever the user is touching. Very simple but I cannot make it work. Any help is highly appreciated. Thanks! EDIT Turns out the problem is this line of code in touchesBegan : ts = [NSMutableSet setWithSet: [event touchesForView:self]]; That I changed into: ts = [[NSMutableSet