我试图了解这样的事情是否可行,如果可以,我该如何实现这一目标。我想创建一个UIView
它是基于下图响应的其他视图的容器。我知道 aUIView
是其他 UIViews 的容器。我想要做的是能够触摸 aUIImageView
并且当我在主视图中拖动它时,如果它在一侧超出范围,则显示在完全相反的方向上,如图所示. 我希望我能正确解释这个问题。
点击这里查看说明
问问题
222 次
1 回答
0
你可以通过实现 containerUIView
的 touch 方法很容易地实现这一点:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
在touchesMoved
您可以检查您UIImageView
的来源。如果它越过边界(x
小于y
0 或大于容器的尺寸),则只需将其框架重新定位为所需的偏移量。
于 2013-01-04T22:26:28.487 回答