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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:56:35+00:00 2026-05-27T14:56:35+00:00

i can not find what is not working with two buttons i create. the

  • 0

i can not find what is not working with two buttons i create. the buttons will work as intended if there is data in my NSString

plantingEventData.seedingMethod

(if it contains “conventional” or “VR”). but if any other value is in the variable, the button does nothing. the method is still called, and will get into the if statements in the button methods, but will not change the properties. its almost like the buttons are not connected the UIButton. but it works perfect if the variable has “conventional” or “VR” strings in it.

Good

plantingEventData.seedingMethod = @"conventional" or @"VR"

Bad

plantingEventData.seedingMetod = any other value

i create two buttons that will are set up for either one or neither to be selected:

UIButton *conventionalSeedingButton = [UIButton new];
conventionalSeedingButton.frame = CGRectMake(200, ((i * 40) + 143), 20, 20);
conventionalSeedingButton.tag = 1;
[conventionalSeedingButton addTarget:self action:@selector(conventionalSeedingMethodBtn:) forControlEvents:UIControlEventTouchUpInside];
if ([plantingEventData.seedingMethod isEqualToString:@"conventional"])
{
    NSLog(@"convention button is set to true");
    [conventionalSeedingButton setImage:[UIImage imageNamed:@"radio-btn-selected.png"] forState:UIControlStateNormal];
    conventionalSeedingButton.selected = TRUE;
}
else
{
    NSLog(@"convention button is set to false");

    [conventionalSeedingButton setImage:[UIImage imageNamed:@"radio-btn.png"] forState:UIControlStateNormal];
    conventionalSeedingButton.selected = FALSE;
}

UIButton *VRSeedingButton = [UIButton new];
VRSeedingButton.frame = CGRectMake(200, ((i * 40) + 143), 20, 20);
VRSeedingButton.tag = 2;
[VRSeedingButton addTarget:self action:@selector(VRSeedingMethodBtn:) forControlEvents:UIControlEventTouchUpInside];
[VRSeedingButton setImage:[UIImage imageNamed:@"radio-btn.png"] forState:UIControlStateNormal];
if ([plantingEventData.seedingMethod isEqualToString:@"VR"])
{
    NSLog(@"VR button is set to true");

    [VRSeedingButton setImage:[UIImage imageNamed:@"radio-btn-selected.png"] forState:UIControlStateNormal];
    VRSeedingButton.selected = TRUE;
}
else
{
    NSLog(@"VR button is set to false");

    [VRSeedingButton setImage:[UIImage imageNamed:@"radio-btn.png"] forState:UIControlStateNormal];
    VRSeedingButton.selected = FALSE;
}

the methods the buttons call:

-(IBAction)conventionalSeedingMethodBtn:(id)sender
{        
    NSLog(@"self.conventionalSeedingMethodButton.selected: %@", self.conventionalSeedingMethodButton.selected ? @"YES" : @"NO");
    if (self.conventionalSeedingMethodButton.selected)
    {
        NSLog(@"switching from true to false");
        [self.conventionalSeedingMethodButton setImage:[UIImage imageNamed:@"radio-btn.png"] forState:UIControlStateNormal];
        self.conventionalSeedingMethodButton.selected = FALSE;
    }
    else
    {
        NSLog(@"switching from false to true");
        [self.conventionalSeedingMethodButton setImage:[UIImage imageNamed:@"radio-btn-selected.png"] forState:UIControlStateNormal];
        self.conventionalSeedingMethodButton.selected = TRUE;
    }

    [self.VRSeedingMethodButton setImage:[UIImage imageNamed:@"radio-btn.png"] forState:UIControlStateNormal];
    self.VRSeedingMethodButton.selected = FALSE;

}

-(IBAction)VRSeedingMethodBtn:(id)sender
{        
    NSLog(@"self.VRSeedingMethodButton.selected: %@", self.VRSeedingMethodButton.selected ? @"YES" : @"NO");

    if (self.VRSeedingMethodButton.selected)
    {
        NSLog(@"switching from true to false");
        [self.VRSeedingMethodButton setImage:[UIImage imageNamed:@"radio-btn.png"] forState:UIControlStateNormal];
        self.VRSeedingMethodButton.selected = FALSE;
    }
    else
    {
        NSLog(@"switching from false to true");
        [self.VRSeedingMethodButton setImage:[UIImage imageNamed:@"radio-btn-selected.png"] forState:UIControlStateNormal];
        self.VRSeedingMethodButton.selected = TRUE;
    }

    [self.conventionalSeedingMethodButton setImage:[UIImage imageNamed:@"radio-btn.png"] forState:UIControlStateNormal];
    conventionalSeedingMethodButton.selected = FALSE;
}

i’m baffled =?

  • 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-27T14:56:36+00:00Added an answer on May 27, 2026 at 2:56 pm

    Your code is a bit confusing. Looks like you have a mix of stuff defined in Interface Builder along with stuff you’ve created programmatically.

    If your intent is to use IB:

    1. Don’t create new buttons programmatically and make sure the IB buttons are configured correctly. You can configure the buttons in viewDidLoad if you want to change/set any properties.

    If your intent is to create/configure the buttons programmatically:

    1. Your buttons are not added to a view. This means that whatever buttons you are seeing in your app must have been added somewhere else (likely IB).

    2. You are not assigning the buttons to iVars. This is ok but you are referring to iVars in your event handlers. If no iVars, retrieve the buttons via their tag properties.

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

Sidebar

Related Questions

I can not find how to implement a design in C++. In the language
HEllo , i can not find any way to get horizontal or/and vertical resolution
I have looked all over the web and I can not find the information
How can i read cookie set date? In rails api I can not find
I want to flip an imageView (left/right), but I can not find a UIView
I think this is a simple question, but I can not find the answer
I simply can not get Visual Studio 2005 to find the System.Configuration.ConfigurationManager class. Here
I know on client side (javascript) you can use windows.location.hash but could not find
I am not able to find a way to set TransactionIsolation in ejb. Can
I can't find the is not operator in C#. For example I have the

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.