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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:25:01+00:00 2026-05-23T22:25:01+00:00

How to push a view using a button in a navigation controller? I tried

  • 0

How to push a view using a button in a navigation controller?
I tried to follow this example:
http://www.cimgf.com/2009/06/25/uitabbarcontroller-with-uinavigationcontroller-using-interface-builder/

This is exactly what I need, I have an UITabBarController with 4 tabs and one of them is an UINavigationController. I want to push that view containing the navigation controller from the first view- which is a simple UIView. It doesn’t work, I tried also with a programmatically created button and nothing happens. Any pointers?

Here’s the code I have

@interface HomeViewController : UIViewController {

}

-(IBAction)pushViewController:(id)sender;

@end

---

#import "HomeViewController.h"
#import "NewViewController.h"

@implementation HomeViewController

-(IBAction)pushViewController:(id)sender {
        NewViewController *controller = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
    [[self navigationController] pushViewController:controller animated:YES];
    [controller release], controller = nil;
}

Here is also the screenshot with the connections
http://imageshack.us/photo/my-images/847/screenshot20110719at620.png/

I’ve tried what you guys suggested and still nothing, the buttons( whether they are created in Interface Builder or programmatically ) act like they’re not linked to any method.

  • 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-23T22:25:02+00:00Added an answer on May 23, 2026 at 10:25 pm

    Put this where you want to create the button: (e.g. the Root VC’s -viewDidLoad)

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100.0, 100.0, 100.0, 40.0);
    [button setTitle:@"Press" forState:UIControlStateNormal];
    [viewController.view addSubview:button];
    
    [button addTarget:self action:@selector(didPressButton:) forControlEvents:UIControlEventTouchUpInside];
    

    And implement this method:

    - (void)didPressButton:(UIButton *)sender
    {
        UIViewController *viewController = [[[UIViewController alloc] init] autorelease];
        [self.navigationController pushViewController:viewController animated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a navigation controller to drill into a detail view when a cell
I am using UINavigationController to push and pop a view. I used [[self navigationController]
I have a problem where I can successfully push a new view controller from
I'm using a navigation controller for my app, because a lot of my views
hello all i am using this code to show flip animation...... i have a
I have a custom UITableViewCell which is part of a navigation controller. The cell
Should I push keypresses to vehicles when they're pressed, or should vehicles pull keys
I have a thread push-backing to STL list and another thread pop-fronting from the
Is it possible to programmatically push files to a wireless SD card - like
I've done some research into server push with javascript and have found the general

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.