0

我正在为 iphone 开发 ios 应用程序。我正面临登录屏幕的问题。我已经开发了带有登录屏幕的应用程序。但是现在我想首先提供登录选项,登录后我想显示我的实际应用程序屏幕。

所以我对代码所做的如下......

首先,在没有登录屏幕的情况下,我在 appdeleget.m 中调用的函数如下..

-(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;


}

这是我从(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method of AppDelegete.-m文件调用的函数

现在我想显示登录屏幕所以我做了一个登录 Viewcontroller 然后我修改了我的 -

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

用这个方法..

- (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;




}

我在登录屏幕上有一个按钮,单击该按钮我正在做与我之前在我的应用程序中没有登录屏幕时所做的相同的事情,如下所示。

- (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];




}

现在的问题是一切正常,但是在加载应用程序视图时单击该按钮后,没有一个导航过程有效。我无法使用以下代码导航到任何其他屏幕..

 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];

我知道我在代码的某个地方犯了一些愚蠢的错误,所以任何人都可以指导我如何解决这个问题..

4

1 回答 1

1

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];
}
于 2013-06-08T08:05:46.697 回答