Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Iphone image animation

iphone animation method custom

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 JakeWelton

JakeWelton

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 152 posts

Posted 15 May 2013 - 04:21 AM

Hello all,

 

I'm trying to play an animation when a button is pressed. I successfully have this section of code running:

// Load images
    NSArray *imageNames = @[@"win_1.png", @"win_2.png", @"win_3.png", @"win_4.png",
                            @"win_5.png", @"win_6.png", @"win_7.png", @"win_8.png",
                            @"win_9.png", @"win_10.png", @"win_11.png", @"win_12.png",
                            @"win_13.png", @"win_14.png", @"win_15.png", @"win_16.png"];
    
    NSMutableArray *images = [[NSMutableArray alloc] init];
    for (int i = 0; i < imageNames.count; i++) {
        [images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
    }
    
    // Normal Animation
    UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 95, 86, 193)];
    animationImageView.animationImages = images;
    animationImageView.animationDuration = 1;
    
    [self.view addSubview:animationImageView];
    [animationImageView startAnimating];

But the problem is i cannot get it to run within a method so i can call it when needed.

 

I have narrowed the problem down to the second to last line. Where it says "self.view". I'm not sure what to change this to, i know it needs to be an object, but an object of what??

 

Can anyone offer any help??

 

Thanks,

Jake

 

P.s i am a beginner with iPhone development so please be patient with me.


sig.jpg

"Before you judge someone, walk a mile in their shoes; after that, who cares?! Their a mile away and you've got their shoes!"


#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 18 May 2013 - 06:57 PM

I'm not sure, but I think for calling it from a method  you need to work with self.view.superview, since .view is like local, that's why when you get it out of context it doesn't work



#3 kevinvwallace

kevinvwallace

    CC Lurker

  • New Member
  • Pip
  • 5 posts

Posted 15 July 2013 - 03:19 AM

Hello welton,

 

   I am agree with Black Rabbit, I am also suggest you same thing. Follow it and see whats happen.?






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download