0
我需要將touchView中的imageView標籤移動。我有10個圖像視圖和標籤是從1到10.我需要在將圖像移動到手指上時獲取imageView標籤。我怎樣才能得到多個成像視圖與觸摸移動標籤?
我可以能夠通過得到這個,
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint location = [[touches anyObject] locationInView:self.view] ;
CGRect fingerRect = CGRectMake(location.x, location.y, 1, 1);
for(UIImageView *view in self.view.subviews)
{
CGRect subviewFrame = view.frame;
if(CGRectIntersectsRect(fingerRect, subviewFrame))
{
//we found the finally touched view
}
}
}
,但我不想使用for
循環。有沒有其他的替代方案來獲取imageview,這是我的舉動?任何幫助將不勝感激。
謝謝。
這隻有在視圖不重疊時纔有效。當它們重疊時,它將返回最上面的視圖。 – 2014-10-10 13:32:15
感謝CarouselMin.It效果很好。 – Thangavel 2014-10-10 13:37:38