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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:26:43+00:00 2026-05-28T01:26:43+00:00

I tried a few things myself, but couldnt really get the handle around it.

  • 0

I tried a few things myself, but couldnt really get the handle around it.
I wanna do two things:
First the user can press one of three buttons – They all link to the same ViewController, but when User Presses the first button three labels change accordingly in this second ViewController. And then the user can enter some data which will be displayed in the third view, also accordingly on which button was pressed in the first view.
I tried it with IF Statements, e.g. (IF ViewController.button1waspressed == True) and it didnt really work. I also tried it with tags e.g. (Button1.tag = 1)

Could someone give me a short example on how this could work?

FirstViewController.m

  - (IBAction)switch:(id)sender;

{
SecondViewController *second =[[SecondViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];

SecondViewController.m

  - (void)viewDidLoad
 {
[super viewDidLoad];

if (sender == self.button1) {
    NSString *greeting = [[NSString alloc] initWithFormat:@"Randomtext"];
    self.label.text = greeting; 
}



}

The problem is obvious in this one, SecondViewController cant see the property from the first one. (And yes I imported the FirstViewController and vice versa)

  • 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-28T01:26:43+00:00Added an answer on May 28, 2026 at 1:26 am

    Your buttons should all directly call IBActions (methods defined like so):

    - (IBAction)doSomething:(id)sender;
    

    Defining them as IBActions exposes them to be connected with the blue connection lines in interface builder. Once you’ve hooked them up and the method is being called, you can simply use an equality check on the sender parameter, which the calling button will automatically set as itself.

    if (sender == self.myButton) {
        // do something
    }
    

    Here I’m assuming that you’ve got a property called myButton in your ViewController, which would be an IBOutlet:

    @property (nonatomic, retain) IBoutlet UIButton *myButton;
    

    This exposes that property to be connected with the blue connection lines in interface builder, so your ViewController will know exactly which button you’re talking about when you say myButton.

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

Sidebar

Related Questions

I've tried a few things but can't seem to get my head round it.
I have tried a few things to solve this problem but I can't seem
I've searched around a bit for this and tried a few things and can't
I can't get it any bigger I have tried a few html variations... I
This is probably simple, but I've tried a few things and couldn't find a
I have tried quite a few codes but none of them seem to work
Been stuck on this for a while and tried a few various things. Basically
Sounds funny, but how can I get the external IP address from a client?
I've tried a few Asus Ones, and found that even switching between multiple windows
I am trying to determine a file's mime type. I've tried a few methods,

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.