2013-11-28 183 views
0

我有FavouriteViewController其中我有一個按鈕點擊按鈕我提出了一個模態稱爲LoginViewController(使用故事板)的視圖。解僱目前視圖控制器後無法推視圖控制器

在這個頁面(LoginViewController),我再次有按鈕,點擊我解散我的模態視圖控制器,解僱後我再次回到FavouriteViewController現在在這個頁面上,當我嘗試推我的視圖控制器它doesn推動。

這裏是我的代碼片段,

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

我的日誌顯示:

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

請幫幫忙,並在此先感謝。

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

**我也試過:**

代碼在我LoginViewController.m

- (IBAction)LoginViaFb:(id)sender{ 

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

     FavoriteTabViewController *fav=[[FavoriteTabViewController alloc] init]; 
     [email protected]"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]; 
    } 

} 

但它仍然沒有幫助,顯示some values --- null

+0

xcode顯示任何警告? – freelancer

+0

確實得到任何異常或錯誤。你正在使用的xcode的版本 – codercat

+0

我沒有在我的日誌中得到任何錯誤,並且我使用的是xocde 5.0 – Krunal

回答

2

這是什麼方式我對你說。

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


} 
+0

Dude如果我不初始化,那麼我將如何調用這個?' - (void)Loginsuccessfull' – Krunal

+0

我告訴過你可以在這裏使用委託概念。在LoginViewController中用一個方法loginsuccessfull聲明協議,並將該委託設置爲FavoriteTabViewController。在調用LoginViaFb之前調用LoginViewController的這個方法,調用該委託方法。 –

+1

你能告訴我如何? – Krunal

相關問題