如何确定UIImageView
当前在视图中触摸了哪些内容?它们是动态创建的UIImageViews
,并且基于标签。我还将使用带有我的对象和数组索引的标签以供参考。我已经读过我需要在UIButton
这种情况下使用,但问题UIButton
是我不能将它拖到它自己的范围之外。
我需要知道如何通过标签获取特定的动态创建的按钮,以便检测UIImageView
要在TouchesMoved
.
UIImageViews
这是从我的对象创建的代码:
for (ObjectClass *obj in [self myDelegate].theObj)
{
CGRect rect = CGRectMake(obj._sX + (obj._sW / 2),obj._sY + (obj._sH / 2),10,10);
handlerImg = [[UIImageView alloc] initWithFrame:rect];
handlerImg.backgroundColor = [UIColor yellowColor];
[[self view] addSubview:handlerImg];
handlerImg.tag = z;
[handlerImg setUserInteractionEnabled:YES];
z++;
}
然后我的 touchesMoved 事件代码:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if (drag == YES)
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self.view];
ObjectClass *obj = [[self myDelegate].theObj objectAtIndex:currHandler]; //Get object based on selected UIImageView
if ([touch view] == handlerImg) //Identify which UIImageView is selected
{
someImage.center=location;