【发布时间】:2011-07-30 17:44:19
【问题描述】:
如何将触摸限制在特定区域或UIView?
换句话说,我在视图上有一个UIButton,但它似乎被触摸禁用了。
我还应该写,触摸可以做我想做的事,但是,就像我说的,我失去了对UIButtons 的控制。
@Implementation
...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
...
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
...
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
...
}
我解决了我的问题...
(我的错误)我制作了一个较小的 UIView,UIButtons 位于其外部。子视图附加到该 UIView。 (我可以看到按钮,但我什至无法按下它们)
解决方案(其中 2 个有效):
- 将 UIButtons 的子视图添加到 self.view
- 或...将较小的 UIView 放大到 340 x 480。
【问题讨论】:
-
您能否提供更多详细信息?你如何处理触摸,你的视图层次结构是什么?..