登录不起作用后,Facebook IOS SDK导航到另一个控制器

时间:2014-12-31 12:34:32

标签: ios iphone facebook facebook-login facebook-ios-sdk

我已按照Facebook IOS SDK Docs中提到的所有步骤进行操作。

我的ViewController.h文件如下

#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
@interface ViewController : UIViewController <FBLoginViewDelegate>


@end

我的ViewController.m文件如下

#import "AppDelegate.h"
#import "ViewController.h"
#import "pageLike.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet FBLoginView *fbloginbtn;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet FBProfilePictureView *fbimage;
@property (weak, nonatomic) IBOutlet UILabel *status;

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.fbloginbtn.readPermissions = @[@"public_profile",@"email",@"user_friends"];
self.fbloginbtn.publishPermissions = @[@"publish_actions"];
self.fbloginbtn.delegate =self;
// Do any additional setup after loading the view, typically from a nib.
if(FBSessionStateOpen){
    pageLike *pg=[self.storyboard instantiateViewControllerWithIdentifier:@"pageLike"];
    [self.navigationController pushViewController:pg animated:YES];
}
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
self.fbimage.profileID=user.id;
self.name.text = user.name;


}

@end

错误跟踪在

下面
2014-12-31 17:59:09.830 fbconnect[2274:96019] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: __view_impression_identifier__)'
*** First throw call stack:
(
    0   CoreFoundation                      0x0110a946 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x009f2a97 objc_exception_throw + 44
    2   CoreFoundation                      0x00ffdbbc -[__NSDictionaryM setObject:forKey:] + 940
    3   CoreFoundation                      0x0107a210 -[NSMutableDictionary setObject:forKeyedSubscript:] + 48
    4   fbconnect                           0x0007c1b8 -[FBViewImpressionTracker logImpressionWithView:identifier:parameters:] + 76
    5   fbconnect                           0x000a8428 -[FBLikeControl drawRect:] + 183
    6   UIKit                               0x0175c95c -[UIView(CALayerDelegate) drawLayer:inContext:] + 519
    7   QuartzCore                          0x04ef9d61 -[CALayer drawInContext:] + 118
    8   QuartzCore                          0x04ef9c97 _ZL16backing_callbackP9CGContextPv + 96
    9   QuartzCore                          0x04dde4fe CABackingStoreUpdate_ + 2788
    10  QuartzCore                          0x04ef9c2f ___ZN2CA5Layer8display_Ev_block_invoke + 93
    11  QuartzCore                          0x04f2f416 x_blame_allocations + 15
    12  QuartzCore                          0x04ef9a95 _ZN2CA5Layer8display_Ev + 1591
    13  QuartzCore                          0x04ef9ce6 -[CALayer _display] + 33
    14  QuartzCore                          0x04ef9456 _ZN2CA5Layer7displayEv + 142
    15  QuartzCore                          0x04ef9cc0 -[CALayer display] + 33
    16  QuartzCore                          0x04eedef6 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 322
    17  QuartzCore                          0x04eedf7c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 38
    18  QuartzCore                          0x04e4c3c6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
    19  QuartzCore                          0x04e4d78c _ZN2CA11Transaction6commitEv + 392
    20  QuartzCore                          0x04e4de58 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    21  CoreFoundation                      0x0102d9de __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    22  CoreFoundation                      0x0102d920 __CFRunLoopDoObservers + 400
    23  CoreFoundation                      0x0102335a __CFRunLoopRun + 1226
    24  CoreFoundation                      0x01022bcb CFRunLoopRunSpecific + 443
    25  CoreFoundation                      0x010229fb CFRunLoopRunInMode + 123
    26  GraphicsServices                    0x028da24f GSEventRunModal + 192
    27  GraphicsServices                    0x028da08c GSEventRun + 104
    28  UIKit                               0x016d18b6 UIApplicationMain + 1526
    29  fbconnect                           0x00079a0d main + 141
    30  libdyld.dylib                       0x060dcac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

我创建了另一个名为pageLike的视图控制器,我需要在用户登录后实际导航

1 个答案:

答案 0 :(得分:0)

检查pageLike控制器并删除所有fb登录视图控制器,因为它们可能会产生问题。