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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:52:03+00:00 2026-05-22T18:52:03+00:00

Hey! I have a xib file were i would like a round rect button

  • 0

Hey!
I have a xib file were i would like a round rect button to stay highlighted after it is pressed. I also would like to have a different button that is pressed after the first one that takes you to the next page. How can I do this. Some code would be greatly appreciated!

This is my .h:

#import <UIKit/UIKit.h>

@interface Test1ViewController : UIViewController {

    IBOutlet UIButton *button1;
    IBOutlet UIButton *button2; 


}

-(IBAction) buttonPressed:(id)sender;
-(IBAction) secondButtonPressed:(id)sender;
- (void)flipButton;


@end

This is my .m:

#import "Test1ViewController.h"
#import "Page2.h"

@implementation Test1ViewController

-(IBAction)buttonPressed:(id)sender
{
    [self performSelector:@selector(flipButton) withObject:nil afterDelay:0.0];
}

- (IBAction)secondButtonPressed {
    if ( button1.selected ) {

        Page2 *page2 = [[Page2 alloc] initWithNibName:@"Page2" bundle:nil];
        page2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentModalViewController:page2 animated:YES];
        [page2 release];

    }
}




/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)flipButton {
    if ( button1.selected ) {
        button1.highlighted = NO;
        button1.selected = NO;
    } else {
        button2.highlighted = YES;
        button2.selected = YES;
    }
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end

Thanks a lot for all the help!

  • 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-22T18:52:04+00:00Added an answer on May 22, 2026 at 6:52 pm

    You will have to use the highlighted property of the button to set the state as highlighted or otherwise. However doing immediately on Touch Up Inside seems to reset it. So we delay the change until the next run loop starts. Do this on the method called on touch.

    -(IBAction)buttonPressed:(id)sender
    {
        [self performSelector:@selector(flipButton) withObject:nil afterDelay:0.0];
    }
    

    and define the flip method as follows –

    - (void)flipButton {
        if ( self.button.selected ) {
            self.button.highlighted = NO;
            self.button.selected = NO;
        } else {
            self.button.highlighted = YES;
            self.button.selected = YES;
        }
    }
    

    You can later check on the method called on tap of the other button whether self.button.selected is YES or not and then act on it.

    - (IBAction)secondButtonPressed {
        if ( self.button.selected ) {
            // Load next page.
        }
    }
    

    Better Approach

    Use a UISwitch. Don’t you think that it is a natural fit.

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

Sidebar

Related Questions

Hey I have a view that has a button that when pressed should modally
Hey I have a gridView and I would like to extract the PhotoPath (ftppath
Hey I have a .NET .aspx page that I would like to run every
Hey everbody, i'm having problem with a simple question. I have a NavigationController, 01.xib
Hey I have this configuration in my web.config <log4net> <appender name=LogFileAppender type=log4net.Appender.FileAppender> <param name=File
Hey have method called voted? that sees if someone voted. Where would I put
Hey I have made up a plist file that has an array of strings
Hey I have a windows server running python CGI scripts and I'm having a
Hey i have this div that shows as a popup: <div class=popup> </div> Then
Hey all - I have an app where I'm authenticating the user. They pass

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.