所以我得到了一个NSLog,它在视图中获得触摸位置
select days, date(date_event) + column * interval '1 day'
from tbl_user_marketing_program as programtable
之后我检查触摸是否在标签中
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
for (UITouch *touch in touches)
{
CGPoint location=CGPointMake([touch locationInView:self.view].x,fabs(height-[touch locationInView:self.view].y));
NSLog(@"Touched:%f %f",location.x,location.y);
当我触摸upgradeLabel时它有输出,但是当我触摸dollarPerSecUp标签时没有输出且代码不起作用。在两个标签中都启用了用户交互
答案 0 :(得分:0)
您可以使用以下代码检测节点,而不是位置。
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
}
答案 1 :(得分:0)
问题在于设置userInteractionEnabled。