FavouriteViewController

FavouriteViewController

本文介绍了在解除当前视图控制器后无法pushViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 FavouriteViewController ,其中我点击按钮时有一个按钮我提出了一个名为 LoginViewController的视图 (使用故事板)。

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

在这个页面上( LoginViewController ),我再次有按钮,点击那个我我解雇了我的模态视图控制器,在解雇后我再次回到 FavouriteViewController 现在在这个页面上,当我试图推动我的视图控制器它不会推动。

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.

这是我的代码片段,

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

我的日志显示:

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

请提供帮助,并提前致谢。

-----第2部分-----:

**我也尝试过:**

** I also tried:**

我的 LoginViewController.m中的代码

- (IBAction)LoginViaFb:(id)sender{

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

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

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

}

但它仍无济于事,显示一些值--- null

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

推荐答案

这是什么方式我跟你说过。

This is way what I said to you.



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





#import <UIKit/UIKit.h>

@protocol LoginDelegate;
@interface LoginViewController : UIViewController

@property (assign) id <LoginDelegate> logindelegate;

@end

@protocol LoginDelegate <NSObject>

- (void)loginSuccessfull;

@end





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


}

这篇关于在解除当前视图控制器后无法pushViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 15:46