Sta*_*ash 13 objective-c ios facebook-ios-sdk fbnativedialogs
我已经在这个问题上苦苦挣扎了一段时间,我似乎无法准确地再现它以描述确切的用例.基本上,我正在做的是发出打开原生iOS 6.0 Facebook共享对话框的请求(使用Facebook iOS SDK 3.1.1):
if ([[SocialManager sharedManager] isNativeFacebookShareDialogAvailable]) {
if (!url) {
url = [NSURL URLWithString:@""];
}
if (!imageUrl) {
imageUrl = [NSURL URLWithString:@""];
}
dispatch_async(backgroundQueue, ^{
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
UIImage *image = [UIImage imageWithData:imageData];
if (!image) {
image = [[UIImage alloc] init];
}
if ([FBNativeDialogs canPresentShareDialogWithSession:[FBSession activeSession]]) {
dispatch_async(dispatch_get_main_queue(), ^{
[FBNativeDialogs presentShareDialogModallyFrom:sender initialText:initialText images:@[image] urls:@[url] handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
failBlock([[error userInfo] description]);
} else {
if (result == FBNativeDialogResultSucceeded) {
completionBlock();
} else if (result == FBNativeDialogResultCancelled) {
failBlock(@"User cancelled");
} else if (result == FBNativeDialogResultError) {
failBlock(@"Unknown error");
}
}
}];
});
} else {
LogErr(@"Can't display native share dialog for active session");
}
});
}
Run Code Online (Sandbox Code Playgroud)
在presentShareDialogModallyFrom:sender调用之后,我得到以下崩溃日志:
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x1d161490> was mutated while being enumerated.'
*** First throw call stack:
(0x32ede2a3 0x326b097f 0x32eddd85 0x35da094d 0x32edb62f 0x35da07f5 0x35e7e5e5 0x35e0ccd7 0x35e0cb6d 0x372c490f 0x35e0ca61 0x35e160d5 0x372b783b 0x35e160b1 0x372b711f 0x372b699b 0x372b6895 0x372c5215 0x372c53b9 0x36f5fa11 0x36f5f8a4)
libc++abi.dylib: terminate called throwing an exception
Run Code Online (Sandbox Code Playgroud)
或者我没有崩溃,本地共享对话框显示应该.
堆栈意味着对此时调用的线程进行调用UIRemoteViewControllerCreationRequest,这里有两个不同崩溃的示例:

谢谢你的帮助
在对我的应用程序进行了大量实验并研究 Facebook SDK 源代码之后,我意识到了 3 件事:
自己创建一个SLComposeViewController没有帮助。Facebook SDK 在这方面非常简单,它只是创建与奖金答案中的代码完全相同的控制器。
当您授权 FB 会话时,您的应用程序将被停用一次或多次。这是由出现权限确认警报引起的。
UIRemoteViewController实际上是在SLComposeViewController不同的进程中运行的。
是什么导致了我的错误?
applicationDidBecomeActive:applicationDidBecomeActive:正在用 UI 做一些当 FB 对话框出现时不应该做的事情(触发表重新加载)。另外,还有另一件事需要注意 - 的处理程序presentShareDialogModallyFrom...不会在任何特定线程上调用(请参阅SLComposeViewController文档)。这意味着dispatch_async(dispatch_get_main_queue(), ...)如果您要从处理程序更新 UI,则应该使用处理程序。
编辑:显然,前面的步骤修复了一些崩溃,但其中一个崩溃尚未解决。经过大量谷歌搜索和苹果开发者论坛搜索后,我认为 iOS 6 与遥控器连接和使用中存在一个错误UIAppearance,尤其是UINavigationBar. 我目前正在从我的应用程序中删除使用UIApperance。
| 归档时间: |
|
| 查看次数: |
1134 次 |
| 最近记录: |