I\'ve been trying to redo the work on my app programmatically. (Without the use of storyboards)
I\'m almost done, except making the navigation controller manually.>
Try this one . It will guide you how to use navigation controller.
Programatically creating UINavigationController in iOS
AppDelegate.h
#import
#import "LoginViewController.h"
@interface AppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
@property (strong,nonatomic) UINavigationController *navigationController;
@property (strong,nonatomic) LoginViewController *loginVC;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "LoginViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.loginVC = [[LoginViewController alloc]initWithNibName:nil bundle:nil];
self.loginVC.title = @"Login Page";
self.navigationController = [[UINavigationController alloc]initWithRootViewController:self.loginVC];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
}
Then when you want to push the other view controller , simple use following code to move to another view controller.
- (IBAction)pushMyProfileView:(id)sender
{
self.myProfileVC = [[MyProfileViewController alloc]initWithNibName:nil bundle:nil];
[appDelegate.navigationController pushViewController:self.myProfileVC animated:YES];
}