【发布时间】:2013-03-25 07:12:40
【问题描述】:
我正在尝试将 iOS 应用程序与 Facebook 集成。登录和大多数功能都运行良好,但是当我尝试让 FBWebDialogs 分享用户发布的内容时遇到了一个小问题。如果在发布(调用函数)后直接调用它,但当我尝试从警报视图执行相同操作时崩溃,它开始出现并在完全加载之前突然消失而不会破坏应用程序并且不会引发错误.当用户在 iPhone 的设置中登录时,它使用 iOS 6 中具有原生视图而不是 FBWebDialogs 的新 Facebook 功能工作。 我正在使用第三方库来自定义警报视图,但它与标准警报视图相同。
我认为这是一种不屑一顾的观点,但没有足够的关于 iOS 的知识来确定。任何想法?。谢谢。
代码如下:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex)
{
case 1:
{
[self sharePostOnFacebook];
break;
}
default:
break;
}
}
调用了下一个方法,但模态视图从未完全出现。它只是闪烁然后消失
-(void) sharePostOnFacebook
{
if (shareData !=nil && [[shareData objectForKey:@"success"] boolValue])
{
NSString *caption = [shareData objectForKey:@"caption"];
. ..........
BOOL displayedNativeDialog =
[FBNativeDialogs
presentShareDialogModallyFrom:self
initialText:description
image:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picture]]]
url:[NSURL URLWithString:link]
handler:^(FBNativeDialogResult result, NSError *error) {
.........
}];
// Fallback, show the view controller that will post using me/feed
if (!displayedNativeDialog)
{
[[[self presentingViewController] presentingViewController] dismissModalViewControllerAnimated:YES];
// Put together the dialog parameters
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
.............
nil];
FBSession *activeSession = [FBSession activeSession];
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:activeSession
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
........
}];
}
}
}
【问题讨论】:
-
到目前为止有什么运气吗?我遇到了完全相同的问题。
标签: ios facebook modal-dialog alertview