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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:13:09+00:00 2026-05-26T09:13:09+00:00

I have the following buttons: // First Tab selected UIButton *firstTabButton = [UIButton buttonWithType:UIButtonTypeCustom];

  • 0

I have the following buttons:

// First Tab selected
UIButton *firstTabButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
firstTabButton.frame = CGRectMake(75, 42, 153, 42);
[firstTabButton setTitle:@"FirstTab selected" forState:UIControlStateNormal];
[firstTabButton addTarget:self action:@selector(tabToggler:) forControlEvents:UIControlEventTouchUpInside];
[firstTabButton setBackgroundImage:[UIImage imageNamed:@"FirstTabActive.png"] forState:UIControlStateNormal];
firstTabButton.adjustsImageWhenHighlighted = NO;
[self.view addSubview:firstTabButton];

// First Tab

UIButton *firstTabButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
firstTabButton.frame = CGRectMake(75, 42, 153, 42);
[firstTabButton setTitle:@"FirstTab selected" forState:UIControlStateNormal];
[firstTabButton addTarget:self action:@selector(tabToggler:) forControlEvents:UIControlEventTouchUpInside];
[firstTabButton setBackgroundImage:[UIImage imageNamed:@"FirstTab.png"] forState:UIControlStateNormal];
firstTabButton.adjustsImageWhenHighlighted = NO;
[self.view addSubview:firstTabButton];

//Second Tab Active
UIButton *secondTabButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
secondTabButton.frame = CGRectMake(75, 42, 153, 42);
[secondTabButton setTitle:@"Second Tab Active" forState:UIControlStateNormal];
[secondTabButton addTarget:self action:@selector(tabToggler:) forControlEvents:UIControlEventTouchUpInside];
[secondTabButton setBackgroundImage:[UIImage imageNamed:@"SecondTabActive.png"] forState:UIControlStateNormal];
secondTabButton.adjustsImageWhenHighlighted = NO;
[self.view addSubview:secondTabButton];
appDelegate = [[UIApplication sharedApplication] delegate];

//Second Tab
UIButton *secondTabButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
secondTabButton.frame = CGRectMake(75, 42, 153, 42);
[secondTabButton setTitle:@"Second Tab" forState:UIControlStateNormal];
[secondTabButton addTarget:self action:@selector(tabToggler:) forControlEvents:UIControlEventTouchUpInside];
[secondTabButton setBackgroundImage:[UIImage imageNamed:@"SecondTabActive.png"] forState:UIControlStateNormal];
secondTabButton.adjustsImageWhenHighlighted = NO;
[self.view addSubview:secondTabButton];
appDelegate = [[UIApplication sharedApplication] delegate];

For the first time I’d like to display First tab Active and the 2nd tab.

What the tabToggler method will look like? How do I proceed?

  • 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-26T09:13:10+00:00Added an answer on May 26, 2026 at 9:13 am

    You should just use 2 instances of UIButton and have them declared as properties/ivars in your .h file. Then just switch the properties that make a button look active/inactive in your toggleActiveTab method.

    Like so:

    In .h

    @interface...
    {
      UIButton *_firstButton;
      UIButton *_secondButton;
    }
    

    In .m (loadView or viewDidLoad, depending on whether you use a NIB or not):

    _firstButton = <code to set up the first button>;
    _secondButton = <code to set up the second button>;
    

    Finally, your toggleActiveTab method might look something like this:

    - (void)toggleActiveTab
    {
      BOOL activateSecond = _firstButton.enabled;
      _firstButton.enabled = !activateSecond;
      _secondButton.enabled = activateSecond;
    
      // whatever other setup
    }
    

    Don’t forget to release the 2 buttons in your dealloc method.

    Also: Have you considered using a UITabBarController instead?

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

Sidebar

Related Questions

I have the following markup for buttons (can be changed, but I really don't
A small - little question. I have seen many application having buttons like following.
I have created an alert view with two buttons using the following code: UIAlertView
I'm having the following issue: I have a tab-style app. Eacht tab has its
I have a tab-like button interface to interact with my site using the following
I am trying to do the following. I have a tab bar controller with
Hi I have a tab tab controller and my first tab includes a view
I have the following button <asp:ImageButton ID=button1 runat=server ImageUrl=~/image.jpg CommandName = id CommandArgument =
I have the following button: <Club:RolloverButton runat=server ValidationGroup=Login1 Text=Login ID=LoginButton CommandName=Login CssClass=links /> .links
I have the following simple button with an image as the template. The problem

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.