Reputation: 8790
I am developing ios application for iphone. Am facing problem with the login screen.. i have developed app withoughtlogin screen.but now i want to give login option at first and after login i want to show my actual screens of app.
so what i did with code is as follows...
first of all withought login screen the function which i call in appdeleget.m is as follows..
-(bool)DeafultSideBar{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
ViewController *homeViewController = [[ViewController alloc]init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
[navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbar.png"] forBarMetrics:UIBarMetricsDefault];
SlideTabViewController *rootController = [[SlideTabViewController alloc] initWithRootViewController:navController];
_viewController = rootController;
LeftSlideViewController *leftController = [[LeftSlideViewController alloc] init];
rootController.leftViewController = leftController;
// [FBLoginView class];
self.window.rootViewController = rootController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
this is the function which i m calling from - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method of AppDelegete.
m file
now i want to show login screen so i have made one login Viewcontroller and then i modified my -
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method with this..
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
LogInViewController *logInViewController = [[LogInViewController alloc]init];
self.window.rootViewController = logInViewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
and i have one button in login screen and on click of that button am doing same thing which i done before when no login screen in my app as follows.
- (IBAction)SignInCalled:(id)sender {
AppDelegate *appdelegete=[[AppDelegate alloc]init];
appdelegete.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
ViewController *homeViewController = [[ViewController alloc]init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
[navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbar.png"] forBarMetrics:UIBarMetricsDefault];
SlideTabViewController *rootController = [[SlideTabViewController alloc] initWithRootViewController:navController];
_viewController = rootController;
LeftSlideViewController *leftController = [[LeftSlideViewController alloc] init];
rootController.leftViewController = leftController;
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
//[self presentModalViewController:rootController animated:YES];
appdelegete.window.rootViewController = rootController;
appdelegete.window.backgroundColor = [UIColor whiteColor];
[appdelegete.window makeKeyAndVisible];
[UIView commitAnimations];
// [FBLoginView class];
}
Now Problem is that everything working but after clicking of that button when the view of application is loaded then not a single navigation process works.i cant navigate to any of other screen with the following code..
ViewController *HomeView=[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[self.navigationController pushViewController:HomeView animated:YES];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:HomeView];
[menuController setRootController:navController animated:YES];
i know i have made some silly mistake somewhere in code so can anyone please guide me how to make this problem solve..
Upvotes: 0
Views: 261
Reputation: 4705
Your controller hierarchy looks very complicated and not able to figure out what you want to achieve. Below is the updated code changes that I would make first.
First the App delegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
LogInViewController *logInViewController = [[LogInViewController alloc]init];
self.window.rootViewController = logInViewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
Then the button ibaction
- (IBAction)SignInCalled:(id)sender
{
ViewController *homeViewController = [[ViewController alloc]init];
SlideTabViewController *rootController = [[SlideTabViewController alloc] initWithRootViewController:homeViewController];
LeftSlideViewController *leftController = [[LeftSlideViewController alloc] init];
rootController.leftViewController = leftController;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootController];
self.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:navController animated:YES completion:NULL];
// [FBLoginView class];
}
Upvotes: 1