2016-04-07 40 views
0

我正在为tvOS写一个应用程序 - 它一直工作,直到我把UIButton放在屏幕上。问题是,当添加按钮时,touchesBegan和touchesMoved停止工作。如果我删除按钮,然后touchesBegan和touchesMoved开始再次正常工作。为了实验的利益,我尝试了取消“启用用户交互” - 但这没有任何区别。我也尝试了继承UIButton并添加以下代码:UIButton阻止touchesBegan和touchesMoved

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    [super touchesBegan:touches withEvent:event]; 
    [self.nextResponder touchesBegan:touches withEvent:event]; 
} 

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { 
    [super touchesMoved:touches withEvent:event]; 
    [self.nextResponder touchesMoved:touches withEvent:event]; 
} 

不幸的是,这似乎并不奏效。有人对我接下来会尝试什么有任何建议吗?

+0

除了按钮之外,您还对该视图有什么建议?你想达到什么目的? –

回答

0

根据this answer,该按钮成为一个集中的视图,它获得所有的触摸。你必须让你的观点(你在其中实施touchesBegantouchesMoved)可以聚焦。

相关问题