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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:58:40+00:00 2026-05-25T02:58:40+00:00

I have a UIImage on my MyCartViewController. And i have a button on my

  • 0

I have a UIImage on my MyCartViewController. And i have a button on my BlackFacePlatesViewController. I want this button to set the image on the MyCartViewController to another image, however i can’t seem to get it to work. Here is my code for the button to set the image on the MyCartViewController:

EDIT:

I HAVE 1 BOOL VARIABLE IN VC2 AND WHEN THE BUTTON IS PRESSED IN VC1, I SET THE BOOL AND CREATE VC2. THEN IN THE VIEWWILLAPPEAR METHOD, I SET THE IMAGE ACCORDINGLY. HERE IS THE CODE: THANKS

- (IBAction)outlet1 {
MyCartViewController * imageCart = [[MyCartViewController alloc]init];
imageCart.displayImage = YES;

}

BUTTON THAT THE USER PRESSES ^

THIS IS TO SWITCH PAGES:

- (IBAction)myCart:(id)sender; {
MyCartViewController * first = [[MyCartViewController alloc]init];
first.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:first animated:YES];
[first release];

}

THIS IS THE VIEWWILLAPPEAR METHOD IN VC2:

-(void)viewWillAppear:(BOOL)animated{
if (self.displayImage == YES) {
    UIImage * myImage = [UIImage imageNamed:@"Paddle_3.png"];
    [outletImageView setImage:myImage];
}

}

WOULD THIS WORK? THANK YOU VERY MUCH FOR THE HELP EVERYBODY!!!

  • 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-25T02:58:40+00:00Added an answer on May 25, 2026 at 2:58 am

    You aren’t allocating your object cart properly, and cart2 has nothing to do with cart, apart from being a similar class. You should just make an instance variable in the header file that’s a UIImage which holds the image you want to use in your next UIView, and set it when you use presentModalViewController: Try this. In your .h file,

    @interface MyCartViewController : UIViewController {
      UIImage * imageForNextView;
    }
    

    In your .m file,

    - (IBAction)outlet1:(id)sender; {
      imageForNextView = [UIImage imageNamed:@"Paddle_1.png"];
    }
    
    - (IBAction)outlet2:(id)sender; {
      imageForNextView = [UIImage imageNamed:@"Paddle_2.png"];
    }
    
    - (IBAction)myCart:(id)sender; {
      MyCartViewController * cart2 = [[MyCartViewController alloc]init];
      cart2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
      cart2.newImage.image = imageForNextView;
      [self presentModalViewController:cart2 animated:YES];
      [cart2 release];
    }
    

    I made 2 button methods to illustrate the point of switching the image based on which button was pushed. Remember that imageNamed: caches the UIImage, so if you have a lot, you may have to start looking into other loading methods, all of which can be found here. This should solve your problem.

    Edit: Try this. In your .h file,

    @interface MyCartViewController : UIViewController {
      NSString * nameOfImage;
      UIImageView * imageView;
    }
    
    @property (nonatomic, retain) NSString * nameOfImage;
    

    In the .m file,

    @synthesize nameOfImage;
    
    - (void)viewDidLoad; {
      [super viewDidLoad];
      imageView.image = [UIImage imageNamed:nameOfImage];
    }
    

    Then, when you push to the view, try:

    - (IBAction)myCart:(id)sender; {
      MyCartViewController * cart2 = [[MyCartViewController alloc]init];
      cart2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
      cart2.nameOfImage = @"Paddle_2.png";
      [self presentModalViewController:cart2 animated:YES];
      [cart2 release];
    }
    

    Edit2: This is a tutorial about how to use a UISplitViewController, which has a similar idea, where you press a UITableViewCell, and it changes an image in another UIView. You should look through this, and see if it can help your project.

    Also, try:

    - (IBAction)myCart:(id)sender; {
      MyCartViewController * cart2 = [[MyCartViewController alloc]init];
      cart2.nameOfImage = @"Paddle_2.png";
      [self pushViewController:cart2 animated:YES];
      [cart2 release];
    }
    

    This is another way to move to a new UIView, which may work.

    Hope that Helps!

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

Sidebar

Related Questions

I want to have a UIImage as a background image on a UIView. Here
I currently have this code: UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingPathComponent:[NSString stringWithFormat:@/%@.png, [postsArrayID
On my iPhone app I have a UIImage instance. I want to get a
For example, I have a UIImage (from which I can get a CGImage, CGLayer,
I have an UIImage and I want to set its alpha at 0.00 after
I have a UIImage containing an image with a whole bunch of smaller pictures
I have an UIImage (dimension 320x480) that I want to display with a much
I have a problem with encoding UIImage to the base64 string using this category
I have one app, a UIImage* . I'm painting the image twice: Once in
I have an UIImage that I want to edit (say, make every second row

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.