How To Use UIImageView To View In iPhone

In this application we will see , how to use UIImagesView to view without using Interface Builder. Basically images are working with an infinite loop . Just have a look.

Step 1: Create a View base application using template. Give the application name “Animation”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: We need to add the resources file called as “1.gif”, “2.gif” , “3.gif”,  “4.gif”, “5.gif”, “6.gif” into the resource folder. Select resources and add files existing sources.

Step 4: Open the AnimationViewController.m file and make the following changes in the file.


- (void)viewDidLoad {
UIImageView*animationView = [[UIImageView alloc] initWithFrame:self.view.frame];
animationView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"1.gif"],
[UIImage imageNamed:@"2.gif"],
[UIImage imageNamed:@"3.gif"],
[UIImage imageNamed:@"4.gif"],
[UIImage imageNamed:@"5.gif"],
[UIImage imageNamed:@"6.gif"], nil];

animationView.animationDuration = 1.25;
animationView.animationRepeatCount = 0;
[animationView startAnimating];
[self.view addSubview:animationView];
[animationView release];




Step 5: Now compile and run the application in the Simulator.

You can downloaded SourceCode from here Animation 2

Leave a Comment:

Giannis Konstantas says March 25, 2010

Great tutorial.
Keep up the good work!!!

rafael says September 1, 2010

Sorry…same question in English now.

Very good tutorial, I was racking my brains about it.

Now how do I make a smaller size in my image?

here he will use any view:

Sushant says September 6, 2010

As per your comment, i think you want to know how to use small size of image in this example right? If it is, then you need to use photoshop software for the image change.

Hope this will help you.

Add Your Reply