.mЭлементы перетаскивания UIImageView. Использование NSMutableArray
self.elements=[myElements getElements];
imagesElements = [[NSMutableArray alloc]init];
for(ElemetsList *item in self.elements)
{
UIImageView *oneelement = [[UIImageView alloc] initWithImage:[UIImage imageNamed:item.imgElement]];
oneelement.frame = CGRectMake(item.positionX, item.positionY, item.width, item.height);
oneelement.userInteractionEnabled=YES;
[imagesElements addObject:oneelement];
}
for(UIImageView *img in imagesElements)
[self.view addSubview:img];
Тогда я пытаюсь взаимодействовать с элементами:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
for(UIImageView *img in imagesElements)
{
if([self view] == img)
{
CGPoint location = [touch locationInView:self.view];
img.center=location;
}
}
}
Но "если ([вид самостоятельной] == IMG)" всегда "НЕТ" , Поэтому элементы не тянутся. Как перетаскивать элементы, если они находятся в массиве?
Какова будет основная цель этой линии? 'для (UIImageView * img в imagesElements) [self.view addSubview: img];' – holex