【发布时间】:2015-04-23 09:06:07
【问题描述】:
我试图在 Facebook 登录后从我的视图控制器传递到我的标签栏视图控制器,但它给了我这个错误:
'NSInvalidArgumentException',原因:'Storyboard () 不包含带有标识符的视图控制器 'dashBoardViewController''
这是方法:
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSString *userName = [user first_name];
NSString *userId = [user id];
dashBoardViewController *dashBoardViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"dashBoardViewController"];
dashBoardViewController.first_name = userName;
dashBoardViewController.id = userId;
[self presentModalViewController:dashBoardViewController animated:YES];
}
编辑
//
// ViewController.m
// LoginSampleFB
//
//
#import "ViewController.h"
#import "dashBoardViewController.h"
#import "BFPaperTabBarController.h"
#import <FacebookSDK/FacebookSDK.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.loginButton.delegate = self;
self.loginButton.readPermissions = @[@"public_profile", @"email", @"publish_actions",];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSString *userName = [user first_name];
NSString *userId = [user id];
dashBoardViewController *dashBoardViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"dashBoardViewController"];
dashBoardViewController.first_name = userName;
dashBoardViewController.id = userId;
[self presentModalViewController:dashBoardViewController animated:YES];
}
-(void)loginView:(FBLoginView *)loginView handleError:(NSError *)error{
NSLog(@"%@", [error localizedDescription]);
}
@end
和
//
// ViewController.h
// LoginSampleFB
//
// Created by Gabriel Theodoropoulos on 12/5/14.
// Copyright (c) 2014 Appcoda. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
#import "BFPaperTabBarController.h"
@interface ViewController : UIViewController <FBLoginViewDelegate>
@property (weak, nonatomic) IBOutlet FBLoginView *loginButton;
@property (weak, nonatomic) IBOutlet UIButton *showEvent;
@property (weak, nonatomic) IBOutlet UIButton *goQrcode;
@property (retain, nonatomic) NSString *id;
@property (retain, nonatomic) NSString *first_name;
@end
请上去
【问题讨论】:
-
您是否将
dashBoardViewController作为StoryBoard ID分配给Interface Builder中的任何ViewController?
标签: ios xcode cocoa-touch uiviewcontroller