iOS 8&9 iPad 透過 Twitter 使用 UIActivityViewController 拢欄 对话框在 60 秒内关闭 viewServiceDidTerminateWithError



当通过UIActivityViewController使用Twitter在某些url上分享时,Twitter分享对话框将显示,然后如果用户没有按下帖子足够快就隐藏。这可以在iPad设备上复制,而不是在模拟器中。使用Google Chrome应用程序可以很容易地显示一个快速示例。

  1. 在iPad上打开Google Chrome
  2. 打开URL http://www.telegraph.co.uk/news/worldnews/middleeast/syria/11846382/Russia-is-building-military-base-in-Syria.html
  3. 点击共享按钮
  4. 选择Twitter
  5. Twitter对话框弹出,现在等待60秒。注意,Twitter对话框会在用户按下post之前消失。而且右边的图像从来没有填充过。
  6. 一个错误被记录到控制台:

    viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo {Message=Service Connection Interrupted}
    plugin com.apple.share.Twitter.post interrupted
    plugin com.apple.share.Twitter.post invalidated
    

用URL http://apnews.myway.com/article/20150905/ml--syria-7872368035.html重复步骤2-56. 注意,在60多秒后,对话框仍然打开,右边的图像已被解析为网页的一瞥。我认为ipad上存在一些问题,Twitter无法解析一些url。

在iPhone 5上使用原始URL http://www.telegraph.co.uk/news/worldnews/middleeast/syria/11846382/Russia-is-building-military-base-in-Syria.html重复步骤2-5
6. 注意,在60多秒后,对话框仍然打开,右边的图像已被解析为网页的一瞥。在iPad上,相同的URL没有出现,我认为这是问题的一部分。

我在我的应用程序中使用的代码:

NSArray *myUrlArray = [[NSArray alloc] init];
NSURL *myUrl =  [[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@", @"http://www.telegraph.co.uk/news/worldnews/middleeast/syria/11846382/Russia-is-building-military-base-in-Syria.html"]];
myUrlArray = @[myUrl];
NSMutableArray *applicationActivities = [[NSMutableArray alloc] initWithArray:myUrlArray];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:myUrlArray applicationActivities:applicationActivities];
[controller setCompletionWithItemsHandler:
 ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
     NSLog(@"Completed: %@", completed ? @"YES" : @"NO");
     if(completed){
         // Do Something
     }
 }];
NSArray *excludedActivities = @[UIActivityTypePostToWeibo,UIActivityTypePrint,
                                UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
                                UIActivityTypePostToFlickr,UIActivityTypePostToVimeo,
                                UIActivityTypePostToTencentWeibo, UIActivityTypeAirDrop];
controller.excludedActivityTypes = excludedActivities;
controller.popoverPresentationController.barButtonItem = //Add an anchor to a button bar item on your screen;
[self presentViewController:controller animated:YES completion:nil];

有没有其他人在使用UIActivityViewController通过Twitter分享时遇到这个问题,现在我能想出的唯一解决方案是让我自己的Twitter分享活动并使用它而不是内置的Twitter一个。不过,我真的更喜欢使用内置的Twitter。

更新:如果我传入一个UIImage作为数组中的第二个项目,那么这个问题不会发生。这似乎是Twitter如何从传入的URL生成图像的问题。我目前的计划是自己制作webview的UIImage,并将其传递给Twitter分享按钮,这样它就不依赖于Apple/Twitter来生成图像。

这在多个应用程序中发生的事实强烈表明这不是你的应用程序的问题,你需要让苹果公司知道发生了什么,以便他们能够解决它。

但因为我不想留给你这么简短的答案,所以我将以一首歌的形式详细说明:

If the operating system's broken,
and there's someone you feel like chokin',
don't give the engineer a hug;
file a bug, file a bug, file a bug.
If the sharing service crashes,
and all your hopes, it dashes,
don't stomp your phone into the rug;
file a bug, file a bug, file a bug.
When you find a good workaround,
how you hate bugreporter's UI,
but if your Radar's really sound,
they'll fix it before the pigs fly!
So when you see such bad behavior,
and you really need a savior,
don't ask your question with a shrug;
file a bug, file a bug, file a bug!
File a bug, file a bug, file a buuuuuug!
[At bugreporter dot apple dot coooooom]

谢谢。我整晚都在这里。

最新更新