[英]FBSession.m Crashes in iOS6.0 with FacebookSdk.framework
我正在使用新的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.
*/
请帮忙!
只需在要发布到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];
}
让我知道它是否有效.... !!!
编码愉快!!!
确保您具有社交,帐户,AdSupport框架,并且它们是可选的。 复制FacebookSDK.framework,FacebookSDKResources.bundle,FBUserSettingsViewResources.bundle。 可以在iOS版Facebook开发人员网页上找到它们。 如果问题再次出现,请尝试删除所有框架,然后再次添加它们。 这是框架问题,而不是代码问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.