我有FavouriteViewController
我点击按钮时有一个按钮我正在提出一个名为LoginViewController
的模式视图(使用故事板)。
在这个页面上(LoginViewController
),我再次有按钮,点击即可解雇我的模态视图控制器,解雇后我再次回到此FavouriteViewController
当我尝试推动我的视图控制器它不会推动。
这是我的代码段,
------第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部分-----:
**我也尝试过:**
我的 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];
}
}
但它仍然没有帮助,显示some values --- null
答案 0 :(得分: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];
}