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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:20:38+00:00 2026-06-17T15:20:38+00:00

I probably deserve to get shot by good programmers and great minds alike right

  • 0

I probably deserve to get shot by good programmers and great minds alike right now because of how my current code looks like even if I’m a total noob at Objective-C. Anyway, I’m making a logo quiz wherein the questions are in random order, then for each question the choices are also in random order. Anyway, I already have this code below to check where the page should redirect when an answer is selected:

- (IBAction)answerA:(UIButton *)sender {
if(imgView.image == [UIImage imageNamed:@"1.png"])
{
    if([btnA.titleLabel.text isEqualToString:@"1"])
    {
        [btnA addTarget:self action:@selector(correctView) forControlEvents:UIControlEventTouchUpInside];
    }
    else
    {
        [btnA addTarget:self action:@selector(wrongView) forControlEvents:UIControlEventTouchUpInside];
    }
}
else if(imgView.image == [UIImage imageNamed:@"2.png"])
{
    if([btnA.titleLabel.text isEqualToString:@"2"])
    {
        [btnA addTarget:self action:@selector(correctView) forControlEvents:UIControlEventTouchUpInside];            
    }
    else
    {
        [btnA addTarget:self action:@selector(wrongView) forControlEvents:UIControlEventTouchUpInside];
    }
}


- (IBAction)answerB:(UIButton *)sender {
    if(imgView.image == [UIImage imageNamed:@"1.png"])
    {
        if([btnB.titleLabel.text isEqualToString:@"1"])
        {
            [btnB addTarget:self action:@selector(correctView) forControlEvents:UIControlEventTouchUpInside];
        }
        else
        {
            [btnB addTarget:self action:@selector(wrongView) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    else if(imgView.image == [UIImage imageNamed:@"2.png"])
    {
        if([btnB.titleLabel.text isEqualToString:@"2"])
        {
            [btnB addTarget:self action:@selector(correctView) forControlEvents:UIControlEventTouchUpInside];
        }
        else
        {
            [btnB addTarget:self action:@selector(wrongView) forControlEvents:UIControlEventTouchUpInside];
        }
    }
}

This works but the problem is, you have to click on the button twice for it to go to the corresponding page. I know that the problem is IBAction itself is already an event that triggers once the button is clicked, then I have the code inside the condition statements that would be only triggered if the button is clicked again. My question is, how can I modify this so that if the button is clicked once, it immediately checks for the current question then the correct answer?

  • 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-17T15:20:40+00:00Added an answer on June 17, 2026 at 3:20 pm

    Use following Code. I am writing one method only, you can write second.

    - (IBAction)answerA:(UIButton *)sender {
    if(imgView.image == [UIImage imageNamed:@"1.png"])
    {
      if([btnA.titleLabel.text isEqualToString:@"1"])
      {
          [self correctView];
      }
      else
      {
          [self wrongView];
      }
    }
    else if(imgView.image == [UIImage imageNamed:@"2.png"])
    {
      if([btnA.titleLabel.text isEqualToString:@"2"])
      {
          [self correctView];
      }
    else
      {
          [self wrongView];
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable
Probably I'm just too dump for googling, but I always thought char arrays get
Probably right in front of me, but I am not sure how to set
Probably just something small, but I am using the below code to read the
Probably a stupid question, but I'm quite new to the whole get-and-set-property-kind of programming;
Probably I'm doing something wrong but: In my browser I have a code window.location
Probably a very naive question: I have a list: color = [red,blue,red,green,blue] Now, I
Probably pretty easy, but I can't get it sorted out. I want to redirect
Probably a simple question, but I'm not that good with loading files… Getting my
Probably very silly question, - but I've been specifying submodules up until now in

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.