简体   繁体   中英

Spawning multiple instances of the same UIImageView

I have a UIImageView that I created in the nib builder and was wondering how I would create multiple instances of this same ImageView ? Right now that imageview has code attached to it, so it can move around the screen randomly but I want more than one to spawn in the middle of the screen every few seconds.

Start off by sub-classing UIImageView - override the methods you want.

You'll probably have to set up the object in code rather than using Interface Builder. This is easier than it sounds as most of the properties can be called with the dot (.) syntax.

As for spawning every few seconds; have a look at NSTimer .

Answer to comment:

Try adding your newly created objects to an NSMutableArray then you can iterate through them and call the methods required.

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