5

I need to display array of images in a single view which have various effect in icarousel(time machne,coverflow,etc...)i'm going to use single style where all images have to be displayed.. HERE IS MY CODE IN .M FILE..

UIImage *img=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 290, 400)];
NSLog(@"hi");

img.image=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
                      [UIImage imageNamed:@"Cover_1.png"],
                      [UIImage imageNamed:@"Cover_2.png"],
                      [UIImage imageNamed:@"Cover_3.png"],
                      [UIImage imageNamed:@"Cover_4.png"],
                      [UIImage imageNamed:@"Cover_5.png"],
                      [UIImage imageNamed:@"Cover_6.png"],
                      [UIImage imageNamed:@"Cover_7.png"],nil];

But its not working...Can anyone help it out...

Vishnu
  • 2,243
  • 2
  • 21
  • 44

3 Answers3

6

Update: As per your latest edit, your question entirely changed, hence my answer does not apply.


Use animationImages instead:

UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 290, 400)];
img.animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
                      [UIImage imageNamed:@"Cover_1.png"],
                      [UIImage imageNamed:@"Cover_2.png"],
                      [UIImage imageNamed:@"Cover_3.png"],
                      [UIImage imageNamed:@"Cover_4.png"],
                      [UIImage imageNamed:@"Cover_5.png"],
                      [UIImage imageNamed:@"Cover_6.png"],
                      [UIImage imageNamed:@"Cover_7.png"],nil];

From the UIImageView documentation;

animationImages

An array of UIImage objects to use for an animation.

@property(nonatomic, copy) NSArray *animationImages

Discussion The array must contain UIImage objects. You may use the same image object more than once in the array. Setting this property to a value other than nil hides the image represented by the image property. The value of this property is nil by default.

Availability Available in iOS 2.0 and later. See Also @property image @property contentMode (UIView) Declared In UIImageView.h

Till
  • 27,559
  • 13
  • 88
  • 122
2

Have you tried

   NSArray *frames = [NSArray arrayWithObjects:
   [UIImage imageWithName:@"a.png"],
   [UIImage imageWithName:@"b.png"],
   [UIImage imageWithName:@"c.png"],
   [UIImage imageWithName:@"d.png"],
   [UIImage imageWithName:@"e.png"],
   nil];

   UIImageView *animatedIMvw = [[UIImageView alloc] init];
   animatedIMvw.animationImages = frames;
   [animatedIMvw startAnimating];
janusfidel
  • 8,036
  • 4
  • 30
  • 53
1

Check out this simple example: http://appsamuck.com/day2.html

EDIT

It appears that the homepage got broken, so check this out instead:

http://web.archive.org/web/20090207210729/http://appsamuck.com/day2.html

Guntis Treulands
  • 4,764
  • 2
  • 50
  • 72