我有带有 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];
}