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

  • Home
  • SEARCH
  • 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 7893261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:05:14+00:00 2026-06-03T07:05:14+00:00

Hi I am new to Xcode development for the iPhone and am stuck on

  • 0

Hi I am new to Xcode development for the iPhone and am stuck on implementing a history function.

In layman’s terms I have

4 buttons (each with its own unique image)

(button 1)
(button 2)
(button 3)
(button 4)

and 5 imageviews

(imageview position 1)
(imageview position 2)
(imageview position 3)
(imageview position 4)
(imageview position 5)

Each time a button is clicked (upto 5 times) i need it to be displayed at the appropriate image view.

i.e if button 4 was pressed first it would be displayed at image view 1
if button 3 was pressed second it would be displayed at image view 2 etc.

I would really appreciate some assistance or push in the right direction.

Thanks in advance


Update Code:

viewcontroller.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {


IBOutlet UIImageView *imageview_history_1;
IBOutlet UIImageView *imageview_history_2;
IBOutlet UIImageView *imageview_history_3;
IBOutlet UIImageView *imageview_history_4;
IBOutlet UIImageView *imageview_history_5;

}

// I would think this could be consolidated into one function
-(IBAction)showhistory_1;
-(IBAction)showhistory_2;
-(IBAction)showhistory_3;
-(IBAction)showhistory_4;
-(IBAction)showhistory_5; 

@end



#import ViewController.h"

@interface ViewController ()

@end

@implementation ViewController



// function to add to history
// Need an if/for statement???
// On button event 1 display result at image view_history 1, 
// On button event 2 display result at image view_history 2.

- (IBAction)showhistory_1 {
UIImage *img = [UIImage imageNamed:@"button1"];

[imageview_history_1 setImage:img];

}


@end

//I’m stuck at creating the function. Thanks again.

  • 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-03T07:05:16+00:00Added an answer on June 3, 2026 at 7:05 am

    First, in your xib, give each button a tag number to easily identify it:
    Let’s say that you give button1 a tag of 1, button2 is tag 2, etc.

    I would then change your UIButton actions to all point to the same function:

    .h:

    - (IBAction)show_history:(UIButton)sender;
    

    .m:

    - (void)setNextHistoryImage:(UIImage *)img {
        if (imageview_history_1.image == nil) {
            imageview_history_1.image = img;
        } else if (imageview_history_2.image == nil) {
            imageview_history_2.image = img;
        }  else if (imageview_history_3.image == nil) {
            imageview_history_3.image = img;
        }  else if (imageview_history_4.image == nil) {
            imageview_history_4.image = img;
        }  else if (imageview_history_5.image == nil) {
            imageview_history_5.image = img;
        }
    }
    
    - (IBAction)show_history:(UIButton)sender {
        NSString *imgName = [NSString stringWithFormat:@"button%d", sender.tag];
        UIImage *img      = [UIImage imageNamed:imgName];
        [self setNextHistoryImage:img];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really new to Xcode and iPhone development. I have written a function
I'm new to iPhone development and Xcode in general and have no idea how
Hello I am brand new to xCode and iPhone development. I have two different
I'm new to iPhone development and Xcode, so this might be really obvious. I
I am Abbas,I am new to iPhone Development, Till tomorrow i am using xcode
Hope all of you doing great. I am new in Iphone development using xcode
I'm fairly new to xcode and iPhone development and I'm wondering if it's possible
I am new at iPhone development using xcode 3.2.6 and I am wondering how
I am new to iphone development, and i'm currently using xcode 4.2. I drew
I am new to iphone development. I am using xCode 4.2 with storyboard. I

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.