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 5980671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:50:03+00:00 2026-05-22T21:50:03+00:00

So, pretty new to iPhone dev and learning all the time. I know what

  • 0

So, pretty new to iPhone dev and learning all the time. I know what I want but dont quite know where to start. I have really only dealt with tableView apps before this project so my practical knowledge of imageView’s and custom actions is very much lacking!

I want to have a UIImageView loaded with an image (using an array populated by a fetchedResultsController as images will be stored in a CoreData DB ).

I want an UIButton with action “next” and UIButton with action “previous” which will control the previously mentioned imageViews’ displayed image.

Thus far I have the DB mapped and interface design but am failing to find this answer to these points (I am sure it will be fairly straight forward to those who know).

Any advise or example code would be greatly appreciated.

DetartrateD

@shawnwall code snippet from below…

-(IBAction)nextImage { 
    index++; 
    int imageCount=31; 
    if (index<=imageCount) { 
        NSString* imageName=[NSString stringWithFormat:@"img%i.jpg", index];
        [picture setImage: [UIImage imageNamed: imageName]]; 
    } 
} 

Mutatable array seeded in viewDidLoad:

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Images"      inManagedObjectContext:managedObjectContext];
[request setEntity:entity];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"topImage" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[request setSortDescriptors:sortDescriptors];
[sortDescriptor release];
[sortDescriptors release];

NSError *error = nil;
NSMutableArray *mutableFetchResultsT = [[managedObjectContext executeFetchRequest:request error:&error]mutableCopy];
if (mutableFetchResultsT == nil) {
}

[self setTopImageArray:mutableFetchResultsT];

NSLog(@"%i" , [topImageArray count]);

Image being added to array here:

Images *imageS = (Images *)[NSEntityDescription insertNewObjectForEntityForName:@"Images" inManagedObjectContext:managedObjectContext];

imageS.topImage = selectedImage;


[topImageArray insertObject:imageS.topImage atIndex:0];

NSLog(@"%i" , [topImageArray count]);

…
…

Same method but after I have created a thumbnail i call:

[self updateTopIV];

Which is :

-(void)updateTopIV 
{
topIV.image = [topImageArray objectAtIndex:0];
}

I then have the 2 action buttons (next/previous):

- (IBAction)nextTouch
{
[self showPhoto:1]; 
}

- (IBAction)previousTouch
{
[self showPhoto:-1];
}


 - (void)showPhoto:(NSInteger)numberToAdd
{
    topIV.image = [topImageArray objectAtIndex:currentPhotoIndex + numberToAdd];

}
  • 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-05-22T21:50:04+00:00Added an answer on May 22, 2026 at 9:50 pm

    Put the images in an array, and have the current image’s index in a variable

    NSInteger *currentPhotoIndex;
    
    - (IBAction)nextTouch
    {
        [self showPhoto:1]; // number to add to current, so 1 for next, -1 for previous
    }
    
    - (IBAction)previousTouch
    {
        [self showPhoto:-1];
    }
    
    
    // Actual "Logic"
    
    - (void)showPhoto:(NSInteger)numberToAdd
    {
        NSArray *arrayOfImages = allTheImagesYouWantToShow
        UIImageView.image = [arrayOfImages objectAtIndex:currentPhotoIndex + numberToAdd];
        // Adding one or subtracting one from the current image's index will show the photo
        immediately before or after it. With this method, you can also skip around to any
        number you want.
    }
    

    I think that should do it.

    —
    EDIT:

    currentPhotoIndex should be defined in your header file as you have done. It should be set to the position in the array of the first image you show. For now, lets assume it’s the first one.

    The first time that you show an image, do this:

    currentPhotoIndex = [arrayOfImages indexOfObject:thePhotoI'mShowingRightNow];
    

    Also, good catch. In order to prevent the NSInteger from being out of the array’s bounds, you need something like this:

    - (void)showPhoto:(NSInteger)numberToAdd
    {
        if (currentPhotoIndex > 0 && < arrayOfImages.count) // Makes sure that the int is within the array
        {
            // Show new image
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty new to this iPhone dev thing but so far I have
I am pretty new to php, but I am learning! I have a simple
I'm pretty new to iPhone dev, so any help is appreciated. I am creating
I'm pretty new at this iphone dev stuff and i'm working on some existing
I'm pretty new to iPhone development but I'm close to releasing my first app
I'm pretty new to iPhone application development and I'm doing well so far. But
I am pretty new to iPhone and spent some months on it but.....But i
I'm a long-time web guy who's pretty new to iphone development. I'm finding many
I'm pretty new to Android development and would appreciate some help. All I want
Im pretty new to REST but as far as i have gathered i understand

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.