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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:12:39+00:00 2026-06-06T14:12:39+00:00

In Xcode 4.2, I know that one can use the storyboard segue to have

  • 0

In Xcode 4.2, I know that one can use the storyboard segue to have a push of a button to go to another view.

But say i want to storyboard, but not using segue push, instead code my own button to display another view, how to do it?
Must i include a navigation controller?

EDIT: added source codes

AppDelegate.h

//
//  AppDelegate.h
//  Sandbox1
//
//  Created on 6/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "ViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@property (nonatomic, retain) UINavigationController *navController;

@end

AppDelegate.m

//
//  AppDelegate.m
//  Sandbox1
//
//  Created on 6/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window = _window;
@synthesize viewController;
@synthesize navController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary     *)launchOptions
{
    // Override point for customization after application launch.

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone"     bundle:nil];
    navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    [self.window addSubview:[navController view]];
    [self.window makeKeyAndVisible];

    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
}

- (void)applicationWillTerminate:(UIApplication *)application
{
}

@end

ViewController.h

//
//  ViewController.h
//  Sandbox1
//
//  Created on 6/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "CreateViewController.h"

@interface ViewController : UIViewController {
    CreateViewController *createViewController;
}

- (IBAction)clickButton:(id)sender;

@end

ViewController.m

//
//  ViewController.m
//  Sandbox1
//
//  Created on 6/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ViewController.h"

@implementation ViewController

- (IBAction)clickButton:(id)sender{
    if(!createViewController){
        createViewController = [[CreateViewController alloc] initWithNibName:@"CreateViewController" bundle:nil];
    }
    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.backBarButtonItem = backBarButtonItem;
    [self.navigationController pushViewController:createViewController animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

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

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

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end

CreateViewController.h

//
//  CreateViewController.h
//  Sandbox1
//
//  Created bon 6/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface CreateViewController : UIViewController

@end

CreateViewController.m

//
//  CreateViewController.m
//  Sandbox1
//
//

#import "CreateViewController.h"

@implementation CreateViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (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.
}

#pragma mark - View lifecycle

/*
// 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];
}
*/

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
  • 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-06T14:12:41+00:00Added an answer on June 6, 2026 at 2:12 pm

    I think the button is in FirstViewController. If it is then implement –(IBAction)clickButton and write code and connect it to your bottom in Interface Builder(If you use Interface Builder) . write createViewController object and #import <CreateViewController.h> in FirstViewController.h and you should use UINavigationController.

    In FirstViewController.h,

    #import "CreateViewController.h"
    
    @interface FirstViewController : UIViewController{
    
        CreateViewController *createViewController;
    }
    -(IBAction)clickButton:(id)sender;
    @end
    

    In FirstViewController.m, you just add below method

     -(IBAction)clickButton:(id)sender{
    
    if (!createViewController) {
                    createViewController = [[CreateViewController alloc] initWithNibName:@"CreateViewController" bundle:nil];
    
                }
    
                UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
                self.navigationItem.backBarButtonItem = backBarButtonItem;
                [backBarButtonItem release];
                [self.navigationController pushViewController:createViewController animated:YES];
    }
    

    and in AppDelegate.h,

    #import "FirstViewController.h"
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    @property (strong, nonatomic) FirstViewController *viewController;
    @property (nonatomic, retain) UINavigationController *navControl;
    @end
    

    In AppDelegate.m,

    @synthesize window;
    @synthesize viewController;
    @synthesize navControl;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
        navControl = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    [self.window addSubview:[navControl view]];
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know and have Xcode, but I was wondering if there were any other
I can't stand XCode, but really love OpenFrameworks, and I know it works on
So I have two works computer, one that I use mainly for development, the
I'm having trouble referencing one view controller from another. The code works but I
I can't be the only one that finds Xcode's method of pointing out where
I know the location of the DerivedData folder that Xcode creates once I build
I know nothing about Xcode, except it's a Developer interface from Apple that actually
I know how to build an existing Xcode project using xcodebuild, but I also
I know this is silly question but as a beginner at xcode, and i
I am new to Xcode. I want to know how can I know all

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.