Unable to pushViewController after dismissing present view controller

自闭症网瘾萝莉.ら 提交于 2019-12-25 11:27:03

问题


I have FavouriteViewController in which i have one button on click of button i am presenting a view modally called LoginViewController (using storyboard).

On this page(LoginViewController), i again have button, on click of that i am dismissing my modal view controller, after dismissing i again comes back to FavouriteViewController now on this page when i try to push my view controller it doesn't pushes.

Here is my code snippet,

------ PART 1 -----

FavouriteViewController.m

- (IBAction)LoginClicked:(id)sender {
      NSLog(@"--- Navigated to LoginViewController ---");
    //Navigates to `LoginViewController` using storyboard..
}

LoginViewController.m

- (IBAction)LoginViaFb:(id)sender{

         NSLog(@"--- Inside LoginViafb ---");
         [self dismissViewControllerAnimated:YES completion:NULL];

         FavoriteTabViewController *fav=[[FavoriteTabViewController alloc] init];
         [fav Loginsuccessfull];
}

FavouriteViewController.m

-(void)Loginsuccessfull{
    NSLog(@"--- Inside Loginsuccessfull ---");

    UserDetailsViewController *user=[[UserDetailsViewController alloc] init];
    [self.navigationController pushViewController:user animated:NO];
}

My Log shows:

--- Navigated to LoginViewController ---
--- Inside LoginViafb ---
--- Inside Loginsuccessfull ---

Please help, and thanks in advance.

----- PART 2 -----:

** I also tried:**

Code in my LoginViewController.m

- (IBAction)LoginViaFb:(id)sender{

         NSLog(@"--- Inside LoginViafb ---");
         [self dismissViewControllerAnimated:YES completion:NULL];

         FavoriteTabViewController *fav=[[FavoriteTabViewController alloc] init];
         fav.GoLogin=@"some values"; 
}

and in FavouriteViewController.m

-(void)viewDidAppear:(BOOL)animated{
    NSLog(@"some values --- %@",some values);

     if ([GoLogin isEqualToString:@"some values"]) {
           NSLog(@"Method called");
        [self.navigationController pushViewController:[[UserDetailsViewController alloc] init] animated:NO];
    }

} 

But it still doesn't help, shows some values --- null


回答1:


This is way what I said to you.

FavouriteViewController.m

- (IBAction)LoginClicked:(id)sender {
    NSLog(@"--- Navigated to LoginViewController ---");

    loginVcObc.logindelegate = self;    
}

 #pragma mark LoginDelegate

 - (void)loginSuccessfull {
        UserDetailsViewController *user=[[UserDetailsViewController alloc] init];
       [self.navigationController pushViewController:user animated:NO];
   }

LoginViewController.h

#import <UIKit/UIKit.h>

@protocol LoginDelegate;    
@interface LoginViewController : UIViewController

@property (assign) id <LoginDelegate> logindelegate;

@end

@protocol LoginDelegate <NSObject>

- (void)loginSuccessfull;

@end

LoginViewController.m

#import "LoginViewController.h"

@implementation LoginViewController

@synthesize logindelegate;

- (IBAction)LoginViaFb:(id)sender{

     NSLog(@"--- Inside LoginViafb ---");
    if (self.logindelegate) {
       [self.logindelegate loginSuccessfull];
  }
    [self dismissViewControllerAnimated:YES completion:NULL];


}


来源:https://stackoverflow.com/questions/20259159/unable-to-pushviewcontroller-after-dismissing-present-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!