简体   繁体   中英

Detect same images name {iPhone SDK}

i want create image animation , i have 50 images with png format now i want set images name ... something like this but doesnt work !

my images name are : iamge_0000 to image_0050

pasheAnimation.animationImages  = [NSArray arrayWithObjects:
                                  [UIImage imageNamed:@"pashe_0000.png"],nil];

    [pasheAnimation setAnimationRepeatCount:5];
    pasheAnimation.animationDuration = 4;
    [pasheAnimation startAnimating];

??!?!?!?

jason Code [EDITED] :

NSMutableArray* myImages = [[[NSMutableArray alloc] initWithCapacity:607] autorelease];
    for( int i = 1; i <= 607; i++ ) {
        [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"p%d.png",i]]];
    }

    butterflyView.animationImages = myImages;
    [butterflyView setAnimationRepeatCount:100];
    butterflyView.animationDuration = 0;
    [butterflyView startAnimating];
// There are actually 51 images in this series (0000-0050)     
NSMutableArray* myImages = [[[NSMutableArray alloc] initWithCapacity:51] autorelease];
for( int i = 0; i <= 50; i++ ) {
  [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image_%04d.png", i]]?:[NSNull null]];
}

You actually have 51 images, from zero to fifty.

NSMutableArray *myImages = [NSMutableArray arrayWithCapacity:51];
for (NSUInteger idx = 0; idx <= 50; idx++) {
    NSString *filename = [NSString stringWithFormat:"image_%04d.png", idx];
    UIImage *image = [UIImage imageNamed:filename];
    if (image) {
        [myImages addObject:image];
    }
    else {
        NSLog(@"Could not add %@", filename); // could also throw exception, if you want
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM