与UIActivityViewController initWithActivityItems共享,在iOS7和iOS8上产生不同的结果

时间:2022-05-09 01:12:18

I have an issue with sharing in my app, and am wondering if I am doing something wrong, or if this is possibly a bug in iOS8.

我在分享我的应用时遇到了一个问题,我想知道我是不是做错了什么,或者这可能是iOS8中的一个错误。

In my app I have the ability to share files, if the sharing type supports attachments it attaches the file (such as email), otherwise it shares a String containing a link to the file.

在我的应用程序中,我可以共享文件,如果共享类型支持它附加的附件(比如电子邮件),那么它可以共享包含文件链接的字符串。

In creating the share activity I do something like this (I've greatly simplified my own implementation, but this is an example):

在创建共享活动时,我做了这样的事情(我极大地简化了自己的实现,但这是一个例子):

-(void)showShareButtons:(BOOL)animated{    NSString *textToShare = @"Foobar!";    NSURL *myWebsite = [NSURL URLWithString:@"http://www.*.com/"];    NSString *localPath = [NSTemporaryDirectory() stringByAppendingPathComponent:"temp.foo"];    NSURL *localFile = [NSURL fileURLWithPath:localPath];    NSArray *objectsToShare = @[textToShare, myWebsite, localFile];    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];    NSArray *excludeActivities = nil;    activityVC.excludedActivityTypes = excludeActivities;    [m_viewController presentViewController:activityVC animated:YES completion:nil];}

On iOS7 I receive the options "Message, Mail, Twitter, and Facebook" for sharing, which is what I expect.
-For the Mail and Message it uses the String, the URL and the local file

在iOS7上,我收到了“消息、邮件、Twitter和Facebook”的分享,这是我所期望的。-对于邮件和消息,它使用字符串、URL和本地文件。

-For Twitter and Facebook its only the String and the URL, where the URL is presented as a proper link (not shown in message)

-对于Twitter和Facebook来说,它只有字符串和URL, URL作为一个合适的链接(不显示在消息中)

On iOS8 I only receive the options Message and Mail, both are the same as they are in iOS7.

在iOS8上,我只接收选项消息和邮件,两者与iOS7中的相同。

It seems that it is now limiting it to sharing options which support every item, whereas before it would list items which supported any.

现在看来,它只允许共享支持每个项目的选项,而在此之前,它会列出支持任何项目的选项。

Build info:

构建信息:

Both are being built in xCode6 Beta, and the deployment target is currently set to iOS7.0

两者都是在xCode6 Beta中构建的,部署目标目前被设置为iOS7.0

iOS 8.0(12A4345d) on an iPhone 5(MD295C/A), 7.1.2 (11D257) on 4S (MD241C/A)

iPhone 5上的iOS 8.0(12A4345d) (MD295C/A), 4S上的7.1.2 (11D257) (MD241C/A)

edit: Also, if I set only one option, such as a string, all options are available. So I am able to share to these on both (i.e., they are enabled)

编辑:另外,如果我只设置一个选项,比如字符串,那么所有选项都是可用的。所以我可以在两者上分享。,他们是启用)

1 个解决方案

#1


0  

Actually it is supposed to be other way, in iOs8 UIActivity will list all the sharing sites which is installed on the device. Eg: Facebook, twitter, Vimeo etc. based on the file type you send for initWithActivityItems: method.

实际上,它应该是另一种方式,在iOs8 UIActivity中将列出安装在设备上的所有共享站点。基于你发送给initWithActivityItems的文件类型:method。

But in iOs7 only mail,message etc will be listed in UIActivity,where Facebook,Twitter,Vimeo will be listed only if you have logged in device settings.

但在iOs7中,只有邮件、消息等才会在UIActivity中列出,而Facebook、Twitter、Vimeo只有在你登录了设备设置后才会被列出。

#1


0  

Actually it is supposed to be other way, in iOs8 UIActivity will list all the sharing sites which is installed on the device. Eg: Facebook, twitter, Vimeo etc. based on the file type you send for initWithActivityItems: method.

实际上,它应该是另一种方式,在iOs8 UIActivity中将列出安装在设备上的所有共享站点。基于你发送给initWithActivityItems的文件类型:method。

But in iOs7 only mail,message etc will be listed in UIActivity,where Facebook,Twitter,Vimeo will be listed only if you have logged in device settings.

但在iOs7中,只有邮件、消息等才会在UIActivity中列出,而Facebook、Twitter、Vimeo只有在你登录了设备设置后才会被列出。