1

我有带有 splitViewController 和多个 detailViewController 的 ipad,它工作正常,但我希望当用户单击登录按钮并转到 LoginScreen 时,当在登录屏幕上单击登录按钮时,它应该重新加载整个 splitViewController 并显示第一个屏幕而不是显示我们点击登录按钮的屏幕是我的代码

     - (void) loginPressed
    {
 LoginViewController *targetController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
targetController.modalPresentationStyle = UIModalPresentationFullScreen;

    [self.splitViewController presentViewController:targetController animated:YES completion:nil];
}

}        

这是登录 ViewController 代码中的登录按钮

                [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadRoot" object:self];

    FirstDetailViewController*targetController=[[FirstDetailViewController alloc]init];

    [self.splitViewController pushViewController:targetController animated:YES] ;

应用委托中的通知代码。

  -(void)actionNotificationData:(NSNotification *)notification {



    jani=@"No";


   self.window.rootViewController=splitViewController;
   }

这是我的 RootViewController,它是 tableView 是 splitView Conroller 中的代码,当我们点击任何单元格移动到新视图时

[self.appDelegate.splitViewController viewWillDisappear:YES];
NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]];
[viewControllerArray removeLastObject];


if (row == 0) {


    self.firstDetailViewController=[[[FirstDetailViewController alloc] init]autorelease];
    [viewControllerArray addObject:self.firstDetailViewController];
    self.appDelegate.splitViewController.delegate = self.firstDetailViewController;







  }

if (row == 1) {



    self.secondDetailViewController=[[[SecondDetailViewController alloc]init]autorelease];
    [viewControllerArray addObject:self.secondDetailViewController];
    self.appDelegate.splitViewController.delegate = self.secondDetailViewController;
}

if (row == 2) {
    self.myLearningViewController=[[[MyLearningViewController alloc]init]autorelease];
    [viewControllerArray addObject:self.myLearningViewController];
    self.appDelegate.splitViewController.delegate = self.myLearningViewController;
}


if (row == 3) {
    self.communityViewController=[[[CommunityViewController alloc]init]autorelease];
    [viewControllerArray addObject:self.communityViewController];
    self.appDelegate.splitViewController.delegate = self.communityViewController;
}


if (row == 4) {
    self.reportsViewController=[[[ReportsViewController alloc]init]autorelease];
    [viewControllerArray addObject:self.reportsViewController];
    self.appDelegate.splitViewController.delegate = self.reportsViewController;
}




if (row == 5) {


    self.walkInViewController=[[[WalkInViewController alloc]init]autorelease];

    [viewControllerArray addObject:self.walkInViewController];

    //self.appDelegate.splitViewController.delegate = self.secondDetailViewController;

    self.appDelegate.splitViewController.delegate = self.walkInViewController;


}

if (row == 6) {


    self.postDataViewController=[[[PostDataViewController alloc]init]autorelease];

    [viewControllerArray addObject:self.postDataViewController];


    self.appDelegate.splitViewController.delegate = self.postDataViewController;


}



[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO];    


[self.appDelegate.splitViewController viewWillAppear:YES];
[viewControllerArray release];


}
4

1 回答 1

0

如果没有更多关于如何在多个细节视图控制器之间移动的信息,很难回答这个问题。我假设您是通过将细节控制器嵌入导航控制器并进行推送和弹出来做到这一点的。

如果这是设置,那么您不应该分配初始化 FirstDetailViewController 然后推送它。如果 FirstDetailViewController 首先出现在屏幕上,然后你推到第二个,最后从那里呈现 LoginViewController,你应该做这样的事情:

- (IBAction)signInButtonClicked{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadRoot" object:self];

    UINavigationController *nav = [(UISplitViewController *)self.presentingViewController viewControllers][1]
    [nav popToRootViewControllerAnimated:NO];
    [self dismissViewControllerAnimated:YES completion:nil];
}
于 2013-07-19T15:48:56.117 回答