Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly your case, what happens is this:</p> <ol> <li><p>you create a new image in <code>createNewImage</code>;</p></li> <li><p>this image is animated through the method:</p> <pre><code>-(void)Animation{ imageView.center = CGPointMake(imageView.center.x + X, imageView.center.y + Y); } </code></pre> <p>which animates your <code>imageView</code> ivar;</p></li> <li><p>when you create a new image, after 2 seconds, you reassign it to the <code>imageView</code> ivar, so that the <code>Animation</code> method can animate it when it is called;</p></li> <li><p>at the same time, you have lost the reference to your previous image that you were animating before, so Animation will not animate it anymore.</p></li> </ol> <p>Now what I suggest is trying to change <code>Animation</code> in this way:</p> <pre><code> -(void)Animation{ for (UIView* imgView in self.view.subviews) { imgView.center = CGPointMake(imgView.center.x + X, imgView.center.y + Y); } } </code></pre> <p>So, this will simply animate <em>any</em> subview of your main view. If your only subviews are the images you want to animate, it should be fine.</p> <p>EDIT:</p> <p>From your description in the comments, it seems to me that what happens is that <code>addSubview</code> has the effect of stopping shortly all animations. I don't know if this is related to loading the images from disk, but I remember I also experienced a similar problem time ago. The only approach I see is pre-creating and pre-adding all the UIImageViews you need (or a maximum number of allowed images), make them all hidden and then making them visible again one by one. This would make the logic of your program more complex, but it would work.</p> <p>Another approach could be using <code>CALayer</code>s instead of <code>UIVIew</code>s. Best thing would be using a CABasicAnimation to animate your images.</p> <p>If you want to use UIImageView, you could get <code>[imageView layer]</code> and add this one instead of the view, like this:</p> <pre><code>[[self.view layer] addSublayer:[imageView layer]]; </code></pre> <p>but I am not sure that this approach would work.</p> <p>Hope that his helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload