Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lamfan

macrumors newbie
Original poster
Aug 4, 2008
6
0
Is there any framework can work on it?

I had thinking about using NSTime to set up loading different UIViewImage in every second,

I don't know is that the right way to create animation graphic for iphone.

Any suggestion?
 

caldwelljason

macrumors member
Jul 9, 2008
44
2
UIImageView

Use UIImageView for simple animations.

You set the animationImages to an NSArray of UIImage*. Then you set the animationDuration and animationRepeatCount on your UIImageView. Finally, you need to call startAnimating on the UIImageView. That will cause the animation to cycle through your images animationRepeatCount times, or until you call stopAnimating.

That's a very high-level, simple view of how to start out with animation on the iPhone. You can do more interesting things with layers and so forth, but that's a bugger question...;)
 

jagatnibas

macrumors regular
Jul 28, 2008
126
0
animation not working on the simulator

Hi col i tried doing the following

NSArray *images = [NSArray arrayWithObjects:mad:"groundhog2.jpg",@"noframes.gif"];
UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 300.0, 300.0)];
[imageView setAnimationImages:images];
[imageView setAnimationRepeatCount:2];
//imageView.image = [UIImage imageNamed:mad:"noframes.gif"];//img;
imageView.center = self.center;
self.picView = imageView;

[imageView release];
[self.picView startAnimating];
[self addSubview:picView];

it crashes, why so ?

should it work on simulator ?

Jagat
 

jagatnibas

macrumors regular
Jul 28, 2008
126
0
thanks but ...

i tried the folowing modified code, still it crashes

UIImage* img1 = [UIImage imageNamed:mad:"groundhog2.jpg"];
UIImage* img2 = [UIImage imageNamed:mad:"noframes.gif"];

NSArray *images = [NSArray arrayWithObjects:img1,img2];
UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 300.0, 300.0)];
[imageView setAnimationImages:images];
[imageView setAnimationRepeatCount:2];
//imageView.image = [UIImage imageNamed:mad:"noframes.gif"];//img;
imageView.center = self.center;
self.picView = imageView;
//[imageView startAnimating];
[imageView release];
[self.picView startAnimating];
[self addSubview:picView];
 

jagatnibas

macrumors regular
Jul 28, 2008
126
0
thanks a lot

Thanks a lot. how could I do this.

anyway, it is working now, though one thing is after animation finished the view becomes black. how would i be animating infinitely ? or else after count finishes, how can i stop on the ending image ?

moreover I am doing this in initframe now. I want to do it on tap on the static image. means, first a static image will display, when i click on that the animation will play and go back to previous static image.

please guide me doing that

thanks and regards

Jagat
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Thanks a lot. how could I do this.

anyway, it is working now, though one thing is after animation finished the view becomes black. how would i be animating infinitely ? or else after count finishes, how can i stop on the ending image ?

moreover I am doing this in initframe now. I want to do it on tap on the static image. means, first a static image will display, when i click on that the animation will play and go back to previous static image.

please guide me doing that

thanks and regards

Jagat

Please read the documentation. We are not here to research the answers to basic questions clearly covered in the documentation for you. If you can't use the documentation you shouldn't be programming for the platform.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.