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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:40:55+00:00 2026-06-07T23:40:55+00:00

I have looked on google and stack flow, and although I have found similar

  • 0

I have looked on google and stack flow, and although I have found similar responses, I am still no more wiser then before I set out my hunt for the solution to this problem.

I have one button, that each time pressed I want it to show the next image.

I believe I have to set up an array of all of the images I have in my project to do this, then maybe something like a counter for the button so it knows which image to show in the UIImageView.

So the project is something like this:

1 x view controller, with 1 x UIImageView, 1 x button, and say 5 images.

UIImageView takes up the whole screen, image 1 displayed in UIImageView, button pressed, displays image 2, button pressed again displays image 3, and so on until you get to image 5, once at image 5, if you press the button again, it will go back to the start (image 1).

I am so new that I would like some example code to help please, not to copy and paste but to study to see how it works, and how I can implement similar within my app.

I hope this makes sense. I’m not up with the lingo yet, so idiot proof advise would be good.

  • 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-07T23:40:58+00:00Added an answer on June 7, 2026 at 11:40 pm

    Ok I just whipped up some example for you here

    Define in .h

    UIButton *b;
    UIImageView *i;
    NSArray *a;
    int count;
    

    and write these in .m

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        b = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        b.frame = CGRectMake(0, 0, 100 ,100);
        [b addTarget:self action:@selector(changeImage) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:b];
    
        i = [[UIImageView alloc]initWithFrame:CGRectMake(0, 100, 100, 100)];
        [self.view addSubview:i];
    
        a = [NSArray array];
        //init array with images what you have
    
        count = 0;
        [i setImage:[a objectAtIndex:count]];
    }
    
    -(void) changeImage{
        count = ++count%5;
        [i setImage:[a objectAtIndex:count]];
    }
    

    Do not follow my naming convention, it was an example. You should write it out nicely.
    This should work once you put in the images. Let me know if you have a question but please do google before asking anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked into google and stack over flow and read all the posts
I have looked on google to find a way to remove text on focus
I have looked on Google, and everywhere in the forums. Just learning JavaScript, so
I have looked around on Google and StackOverflow for the answer to this question,
I have looked for solutions to this on google for what seems like an
I have looked for something like this on Google and on this very site,
I have looked on google for answers but I am not satisfied. My Logic:
I have looked ALL over (google searched) and I cannot for the life of
I have looked a lot on google for answers of how to use the
I have looked at the IronPython website and done various Google searches as well

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.