1
votes

I have ipad with splitViewController with multiple detailViewController it work fine but i want that when user click on Login Button and goes to LoginScreen then when sign in button is clicked on login Screen then it should reload the whole splitViewController and show first screen rather then showing the screen from where we clicked the login button here is my code

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

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

}        

here is sign in button in Login ViewController code

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

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

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

Notification code in app delegate.

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



    jani=@"No";


   self.window.rootViewController=splitViewController;
   }

Here is my RootViewController which is tableView is code in splitView Conroller when we clic on any cell move to new view

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


}
1
split view controllers can't do a push, only navigation controllers can do that. After you do the login, you need to dismiss the LoginViewController, not do a push. - rdelmar
if i dismiss the loginViewController then it moves to the the view from which it clicked how to call the view first - user2240329
It's not clear what controllers you have where. What is on screen before you do the presentation? - rdelmar
i want how to simly move from login screen to FirstDetailViewController - user2240329
Yeah, but I can't help you if I don't know what you app structure looks like. Can you answer my last question? Also, from what screen did you click the login button? - rdelmar

1 Answers

0
votes

It's a little hard to answer this without more information on how you're moving between your multiple detail view controllers. I'll assume that you're doing that by having the detail controllers embedded in a navigation controller, and doing pushes and pops.

If that's the setup, then you shouldn't be alloc init'ing a FirstDetailViewController and then pushing it. If FirstDetailViewController was on screen first, then you push to the second one, and finally present the LoginViewController from there, you should do something like this:

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

    UINavigationController *nav = [(UISplitViewController *)self.presentingViewController viewControllers][1]
    [nav popToRootViewControllerAnimated:NO];
    [self dismissViewControllerAnimated:YES completion:nil];
}