我正在使用新的FacebookSdk,我的应用程序在iOS 6.0中运行时崩溃。这是崩溃日志
*** Assertion failure in -[FBSession close], /Users/jacl/src/release/ios-sdk/src/FBSession.m:404
2012-12-12 12:48:49.993 localfave[1406:1d903] uncaughtExceptionHnadler -- Exception FBSession: should only be used from a single thread
2012-12-12 12:48:49.996 test[1406:1d903] Stack trace: (
0 CoreFoundation 0x02d6b02e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x01cd6e7e objc_exception_throw + 44
2 CoreFoundation 0x02d6ae78 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0176cf35 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 localfave 0x000f6e1d -[FBSession close] + 177
5 localfave 0x000f753e +[FBSession setActiveSession:] + 50
6 localfave 0x000fa6ee +[FBSession openActiveSessionWithPermissions:allowLoginUI:allowSystemAccount:isRead:defaultAudience:completionHandler:] + 230
7 test 0x000f7408 +[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:] + 82
8 test 0x00002fc6 -[AppDelegate openSessionWithAllowLoginUI:] + 166
9 test 0x0008adc5 -[FacebookLoginViewController registerFacebook:] + 165
10 libobjc.A.dylib 0x01cea705 -[NSObject performSelector:withObject:withObject:] + 77
11 UIKit 0x00c21920 -[UIApplication sendAction:to:from:forEvent:] + 96
12 UIKit 0x00c218b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
13 UIKit 0x00ce2671 -[UIControl sendAction:to:forEvent:] + 66
14 UIKit 0x00ce2bcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
15 UIKit 0x00ce1d38 -[UIControl touchesEnded:withEvent:] + 546
16 UIKit 0x00c5133f -[UIWindow _sendTouchesForEvent:] + 846
17 UIKit 0x00c51552 -[UIWindow sendEvent:] + 273
18 UIKit 0x00c2f3aa -[UIApplication sendEvent:] + 436
19 UIKit 0x00c20cf8 _UIApplicationHandleEvent + 9874
20 GraphicsServices 0x03057df9 _PurpleEventCallback + 339
21 GraphicsServices 0x03057ad0 PurpleEventCallback + 46
22 CoreFoundation 0x02ce0bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
23 CoreFoundation 0x02ce0962 __CFRunLoopDoSource1 + 146
24 CoreFoundation 0x02d11bb6 __CFRunLoopRun + 2118
25 CoreFoundation 0x02d10f44 CFRunLoopRunSpecific + 276
26 CoreFoundation 0x02d10e1b CFRunLoopRunInMode + 123
27 GraphicsServices 0x030567e3 GSEventRunModal + 88
28 GraphicsServices 0x03056668 GSEventRun + 104
29 UIKit 0x00c1e65c UIApplicationMain + 1211
30 test 0x00002545 main + 213
31 test 0x00002425 start + 53
)
代码是
/*
* Opens a Facebook session and optionally shows the login UX.
*/
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
return [FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
/*
* Callback for session changes.
*/
请帮助!
答案 0 :(得分:0)
只需将此代码写在您要在Facebook上发布的地方,并丢弃您为Facebook集成所做的每一项功能,我认为您已在.h文件中导入#import。
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"ResultCancelled");
} else
{
NSLog(@"Success");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;
[controller setInitialText:@"Awesome App"];
[controller addImage:photoImage.image];
[self presentViewController:controller animated:YES completion:Nil];
}
让我知道它是否正常工作...... !!!
快乐编码!!!!
答案 1 :(得分:0)
确保您拥有社交,帐户,AdSupport框架,并且这些框架是可选的。 复制FacebookSDK.framework,FacebookSDKResources.bundle,FBUserSettingsViewResources.bundle。 它们可以在Facebook Developers for iOS网页上找到。如果问题再次出现,请尝试删除所有框架并再次添加。这是一个框架问题,而不是代码。