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.

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

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic, and free programming tips and tricks and source code            snippets.

3 Responses to “How to use UIImageView to View in iPhone”

  1. Giannis Konstantas says:

    Great tutorial.
    Thanks!!!!
    Keep up the good work!!!

  2. rafael says:

    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:
    initWithFrame:self.view.frame

  3. Sushant says:

    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.

Leave a Reply

Security Code:

learn iphone programming

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Our Mobile Training Courses

EDUmobile.ORG offers the following 4 Mobile Training Courses. Our iPhone Training Course is very popular, with over 200 developers in training.

learn iphone programming
© 2010 EDUmobile.ORG