I am working in iPhone application, Using XCode 4.3.2 tool develop my application (not using story board). When I press a button from homescreen.m to navigate to Login screen, then I run the app, cannot navigate from home to login screen, how to fix this issue?
I tried this:
Class Name – Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
home = [[HomeScreen alloc]init];
UINavigationController *navi =[[UINavigationController alloc]initWithRootViewController:home];
[self.window addSubview:navi.view];
return YES;
}
Class Name – HomeScreen.m
#import "HomeScreen.h"
#import "LoginScreen.h"
@interface HomeScreen ()
@end
@implementation HomeScreen
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title=@"HomeScreen";
UIButton *Button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
Button1.frame = CGRectMake(10, 100, 100, 50);
[Button1 setTitle:@"Homescreen" forState:UIControlStateNormal];
[Button1 addTarget:self action:@selector(GotONext) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:Button1];
// Do any additional setup after loading the view.
}
-(void)GotONext
{
LoginScreen *log =[[LoginScreen alloc]init];
[self.navigationController pushViewController:log animated:YES];
}
Class Name – LoginScreen.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.title=@"LoginScreen";
}

try bellow code…
and on next button method use bellow code…
i hope this help you…
🙂