Paul Andrew Herbert
Paul Andrew Herbert

Reputation: 367

How do I use the 'animationImages' method with programatically created UIImageViews

I have programatically created 15 or so UIImageViews and given them tags.

I have used the [UIView anim...... method to move them about using [self.view viewWithTag:tag] to reference them.

However, [self.view viewWithTag:tag] does not appear to work with animationImages. Xcode states Property animationImages not found on object of type 'UIView'.

I am trying to move them and animate them at the same time. I have spent all day scouring the web for the answer but to no avail.

Can anyone please help?

Upvotes: 2

Views: 220

Answers (1)

iDev
iDev

Reputation: 23278

You need to check if [self.view viewWithTag:tag] is of type UIImageView and then call the animationImages method on that. The warning states that UIView doesn't support animationImages since return type of viewWithTag: is a UIView and not UIImageView.

You can try something similar to this:

UIView *aView = [self.view viewWithTag:tag];

if ([aView isKindOfClass:[UIImageView class]]) {
   UIImageView *imageView = (UIImageView *)aView;
   imageView.animationImages = [NSArray arrayWith....];//some images    
} 

Upvotes: 3

Related Questions