Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:08:03+00:00 2026-06-13T10:08:03+00:00

I am having some trouble loading images from a file into an array. I

  • 0

I am having some trouble loading images from a file into an array. I have used a combination of questions I have found on here, and am out of ideas…. I am new to objective-c and rusty on the rest.

My viewDidLoad simply calls my showPics method, and for testing sake I have the _imgView just show the image at position 1 in the array.

It could very well be a problem with the way I am showing the images as well. I have a ViewController and one ImageView (titled: imgView) in my Storyboard.

here is my showPics method:

-(void)showPics
{
    NSArray *PhotoArray = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:@"Otter_Images"];
    NSMutableArray *imgQueue = [[NSMutableArray alloc] initWithCapacity:PhotoArray.count];
    for (NSString* path in PhotoArray)
    {
        [imgQueue addObject:[UIImage imageWithContentsOfFile:path]];
    }
    UIImage *currentPic = _imgView.image;
    int i = -1;

    if (currentPic != nil && [PhotoArray containsObject:currentPic]) {
        i = [PhotoArray indexOfObject:currentPic];
    }

    i++;
    if(i < PhotoArray.count)
        _imgView.image= [PhotoArray objectAtIndex:1];

}

Here is my viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self showPics];
}

Here is my ViewController.h

@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *imgView;

@end

Please let me know if you need anything else and thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:08:05+00:00Added an answer on June 13, 2026 at 10:08 am

    In your showPics method, other than the initial ‘for-loop’, all of your references to PhotoArray should instead be references to imgQueue. PhotoArray is a list of pathnames. imgQueue is the array of actual UIImage objects.

    -(void)showPics {
        NSArray *PhotoArray = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:@"Otter_Images"];
        NSMutableArray *imgQueue = [[NSMutableArray alloc] initWithCapacity:PhotoArray.count];
        for (NSString* path in PhotoArray) {
            [imgQueue addObject:[UIImage imageWithContentsOfFile:path]];
        }
    
        UIImage *currentPic = _imgView.image;
        int i = -1;
    
        if (currentPic != nil && [imgQueue containsObject:currentPic]) {
            i = [imgQueue indexOfObject:currentPic];
        }
    
        i++;
        if(i < imgQueue.count) {
            _imgView.image = [imgQueue objectAtIndex:1];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble understanding how codeigniters loading works. Well first you have the
I'm having some trouble fading in large images, but only in Chrome. Here's the
I'm having a bit of trouble loading an CSV file into a mysql database.
I have been having some trouble loading the CheckBoxList with data. I have been
I'm having some trouble loading external javascripts using google app engine. I basically have
Having some trouble with R's garbage collection, when passing objects to C++. We have
Im having some trouble writing a getstring function, this is what I have so
I'm working on an iPhone app, and I'm having some compiler trouble. Here's the
Good day all, I am having some trouble with image permissions. I am loading
Morning, I'm having some trouble creating tables/loading fixtures. (symfony 1.4.6 with the bundled Doctrine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.