theomen
theomen

Reputation: 919

Unable to figure out how to load images into a UIScrollView

I have a problem trying to load images to a UIScrollView, and I don't know exactly if the problem remains in the code or in the Xcode tendency to retain deleted images. I have tried all possible options:

  1. Delete and add again.
  2. Delete cache with Clean option
  3. Restore iphone simulator cache

But I'm not sure if the problem is in my code:

fotosJugadores = [[NSArray alloc] initWithObjects:@"cara5.png", @"cara7.png",
     @"cara8.png", @"cara9.png", @"cara11.png", @"cara13.png", @"cara14.png", 
     @"cara15.png", @"cara18.png",@"cara19.png", @"cara20.png", 
     @"cara32.png",@"cara44.png",@"cara51.png", @"cara100.png", @"cara101.png", 
     @"cara102.png",@"cara103.png", @"cara104.png", 
     @"cara105.png",@"cara106.png",@"cara107.png", nil];

numberOfViews = [fotosJugadores count];

for (int i = 0; i <    [fotosJugadores count]; i++) {

    UIImage *myImage = [UIImage imageNamed:[fotosJugadores objectAtIndex:i]];
    CGFloat yOrigin = i * myImage.size.width + 120;
    NSLog(@"my image %@", myImage);

    UIImageView *awesomeView = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, myImage.size.width, myImage.size.height)];
    awesomeView.tag = i;
    awesomeView.image = myImage;
    awesomeView.alpha = 0.5f;
    awesomeView.backgroundColor = [UIColor blackColor];
    [self.jugadorSlide addSubview:awesomeView];
    awesomeView=nil;

}

EDITED: Here it is an screen shoot of the project file system, images are stores in exular/GBC/Caras:

enter image description here

Upvotes: 0

Views: 113

Answers (2)

Kreiri
Kreiri

Reputation: 7850

From your screenshot it seems that you added "Caras" folder as reference. If you add folder as reference, then path to its files in app bundle will be "foldername/filename", not "filename".

Try using

NSString *imagePath = [NSString stringWithFormat:@"Caras/%@", [fotosJugadores objectAtIndex:i]];
UIImage *myImage = [UIImage imageNamed:imagePath];

Upvotes: 1

CitronEvanescent
CitronEvanescent

Reputation: 175

Check the case of your filenames and extensions. Also make sure of your png format. Some 32bits png are not supported.

Is your awesomeView displayed and sized correctly ?

Upvotes: 0

Related Questions