简体   繁体   中英

Move multiple UIImageView objects

I want to add multiple UIImageView objects at run time. I just read that it's possible through NSMutableArray .

But I also want to move all the UIImageViews . Is it possible to track which UIImageView I touched?

Please help me. Any type of help will be appreciated.

Thanks

You may need to rephrase your question but I'll see if I can help you out. To find what view is being touched, you can define the touchesBegan method in your view controller.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject]; //gets the touch object
    [touch.view thisIsAMethod]; 
    //once you declare touch, you can access what view is being touched with touch.view

}

Also, if you want to move a lot of UIImageViews at once, you can make them all subviews of one UIView by calling

[oneBigUIView addSubview:oneUIImageView];

for every UIImageView . Then you can change the position of the UIView to move them all at once, since the coordinates of each UIImageView are in relation to their superview .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM