【发布时间】:2011-07-03 16:30:13
【问题描述】:
如何根据 UIImage 视图的 y 坐标调用方法? 更具体地说,我有一个可拖动的 UIImageView。当它的y坐标大于某个值时,我希望屏幕的颜色发生变化。
拖拽代码:
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
if([touch view] == toggle)
{
CGPoint location = [touch locationInView:self.view];
CGPoint newLocation = CGPointMake(toggle.center.x, location.y);
toggle.center = newLocation;
NSLog(@"%f \n",toggle.center.y);
}
}
【问题讨论】:
-
您必须更具体:坐标何时可见?被感动了?有某种颜色吗?
-
顺便说一句:我删除标签是有原因的——它们毫无意义。
-
怎么拖是什么意思。我猜是通过触摸和拖动。
-
你有一些代码吗?
-
我的问题与拖动无关。我只想知道如何监听 UIImageView 的 y 坐标的变化并根据变化执行方法。
标签: iphone objective-c cocoa-touch uiimageview