我正在尝试执行一些我知道非常简单的事情,但我不确定语法。
首先,我让用户输入Facebook登录信息,然后签名。我的代码然后提取他们的个人资料图片,用户名,电子邮件和Facebook按钮,并将其显示在“LoginiewController”中。 prof pic是一个名为 profilePicture 的视图控制器,用户名为 lblUsername ,电子邮件为 lblEmail ,FB按钮名为 loginButton 即可。
ALL 我想做的是编写一些代码,将这4个值发送到一个ProfileViewController,它不是segue的下一个视图控制器,因此它显示了个人资料图片,用户名,电子邮件和* 注销 *按钮。下面是我的LoginViewController代码:
***仅供参考,代码显示只有FB登录按钮,常规登录按钮和注册按钮的初始视图,其中隐藏了要启动的个人资料图片视图,用户名和电子邮件。登录后,我有相同的视图控制器现在显示个人资料图片,用户名和电子邮件,隐藏哪个登录按钮*没有*点击。
#import "LoginViewController.h"
@interface LoginViewController ()
@end
@implementation LoginViewController
- (void)viewDidLoad {
[super viewDidLoad];
NOLogin.layer.cornerRadius = 3;
[NOLogin.layer setShadowColor:[UIColor blackColor].CGColor];
[NOLogin.layer setShadowOpacity:0.1];
[NOLogin.layer setShadowRadius:0.2];
[NOLogin.layer setShadowOffset:CGSizeMake(0.0, 1.1)];
[NOLogin.layer setBorderColor:[UIColor blackColor].CGColor];
[NOLogin.layer setBorderWidth:0.1f];
self.loginButton.delegate = self;
[self toggleHiddenState:YES];
_signUp.hidden = NO;
NOLogin.hidden = NO;
self.lblLoginStatus.text = @"";
self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
// self.
}
-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = @"";
[self toggleHiddenState:NO];
[self toggleUnhiddenState:YES];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UITabBarController *tabcontroller = (UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@"TabController"];
[self presentModalViewController:tabcontroller animated:YES];
}
-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
NSLog(@"%@", user);
self.profilePicture.profileID = user.objectID;
self.lblUsername.text = user.name;
self.lblEmail.text = [user objectForKey:@"email"];
}
-(void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = @"";
[self toggleHiddenState:YES];
_signUp.hidden = NO;
NOLogin.hidden = NO;
}
-(void)loginView:(FBLoginView *)loginView handleError:(NSError *)error{
NSLog(@"%@", [error localizedDescription]);
}
-(void)toggleHiddenState:(BOOL)shouldHide{
self.lblUsername.hidden = shouldHide;
self.lblEmail.hidden = shouldHide;
self.profilePicture.hidden = shouldHide;
self.begin.hidden = shouldHide;
self.loggedinwallpaper.hidden = shouldHide;
}
-(void)toggleUnhiddenState:(BOOL)shouldShow{
_signUp.hidden = YES;
NOLogin.hidden = YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)unwindToLogin:(UIStoryboardSegue *)segue {
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
/*- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
[segue destinationTabBabController]
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
- (IBAction)j:(id)sender {
}*/
- (IBAction)enter:(id)sender forEvent:(UIEvent *)event {
}
@end
答案 0 :(得分:0)
初始化了想要呈现的ViewController后,您现在可以访问它的&#39;属性(您已经提到的那些属性,并为它们分配了您想要的值)。
-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = @"";
[self toggleHiddenState:NO];
[self toggleUnhiddenState:YES];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UITabBarController *tabcontroller = (UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@"TabController"];
//Get the first controller that will be displayed (could be of a different index, depends on how you set it up)
UIViewController *firstController = [[((UITabBarController *)self.window.rootViewController) viewControllers] objectAtIndex:0];//Modify UIViewController to your View controller class name...
//Now set the properties of that controller to the info you need. I've added one, please continue with the others...
firstController.lblUsername = self.lblUsername;
//Finally, present the tabController.
[self presentModalViewController:tabcontroller animated:YES];
}