Add this line to viewDidLoad(This one is for the situation when you have your images stored in document directory of your project Dynamic):
slideShowTimer=[NSTimer scheduledTimerWithTimeInterval: 3.0 target: self selector:@selector(changeImageSlide) userInfo: nil repeats:YES];
the changeImageSlide
method:
- (void) changeImageSlide
{
totalNoOfImages=[copyOf_myGlobleArrayOfImageIds count];
if (imageCounter>=totalNoOfImages-1)
{
imageCounter=0;
}
NSString *str = [NSString stringWithFormat:@"%@.jpg",[copyOf_myGlobleArrayOfImageIds objectAtIndex:imageCounter]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullImgNm=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:str]];
//=(3*imageCounter+4)%25;
[mainSlideShowImageView setImage:[UIImage imageWithContentsOfFile:fullImgNm]];
[mainSlideShowImageView setTag:[[copyOf_myGlobleArrayOfImageIds objectAtIndex:imageCounter] intValue]];
imageCounter++;
}
OR
use the following(it's for the situation when your images are in the resource folder of your project and you have added them to your project static):
//MAIN SIDE SHOW TASK
//while fetching names from database need to impliment another mutable array ref:information provider
NSArray *imageNames=[[NSArray alloc] initWithObjects:@"1.jpg",
@"2.jpg",
@"3.jpg",
@"4.jpg",
@"5.jpg",
@"6.jpg",
@"7.jpg",
@"8.jpg",
@"9.jpg",
@"10.jpg",
@"11.jpg",
@"12.jpg",
@"13.jpg",
@"14.jpg",
@"15.jpg",nil];
int limit=[imageNames count];
NSMutableArray *tempNames=[[NSMutableArray alloc] init];
for (int i=0; i<limit; i++) {
NSString *str= [NSString stringWithFormat:@"%@",[imageNames objectAtIndex:i]];
[tempNames addObject:[UIImage imageNamed:(NSString *)str]];
}
NSArray *images=tempNames;
NSLog(@"name array=======%@",images);
mainSlideShowImageView.animationImages=images;
mainSlideShowImageView.animationDuration = 75.00;
mainSlideShowImageView.animationRepeatCount = 0; //infinite
[mainSlideShowImageView startAnimating];
//MAIN SlIDE SHOW TASK COMPLETE