UIActivityViewController

UIActivityViewController

本文介绍了UIActivityViewController Facebook和Twitter共享在已发布的iOS版本中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近发布了与fb&两次使用UIActivityViewController就像在应用商店上的之字形应用一样.

We have recently released iPhone app which share to fb & tw using UIActivityViewController like as zigzag app on app store.

由于我的设备用于开发,因此我的设备运行良好.但是下载此应用程序的所有用户都无法使用此功能进行共享.

My device is working perfect as my device is used for development.But all users who downloaded this app not able to share using this function.

NSString *txtToShare = @"Please try this awesome iOS app";
NSArray *objectsToShare = [NSArray arrayWithObjects:txtToShare, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion:^{

}];
if ([activityVC respondsToSelector:@selector(popoverPresentationController)])
{
    // iOS 8+
    UIPopoverPresentationController *presentationController = [activityVC popoverPresentationController];

    presentationController.sourceView = sender; // if button or change to self.view.
}

有人可以告诉我为什么吗?

Can anybody tell me why?

推荐答案

我遇到了同样的问题,并使用以下技术解决了此问题声明了两个常量

I had same issue and I resolved this using following techniqueDeclared two constants

static NSString *const twitterAppBundleStringForOS8 = @"com.atebits.Tweetie2.ShareExtension";
static NSString *const facebookAppBundleStringForOS8 = @"com.facebook.Facebook.ShareExtension";

if ([self.activityType isEqualToString:UIActivityTypePostToFacebook] || [self.activityType isEqualToString:facebookAppBundleStringForOS8]) {
        text = @"abc";
    }
    else if( [self.activityType isEqualToString:UIActivityTypePostToTwitter] || [self.activityType isEqualToString:twitterAppBundleStringForOS8]){
        text = @"cc";
    }

现在工作正常

当我遇到问题时,我有以下代码

When I had issue I had following code

if ([self.activityType isEqualToString:UIActivityTypePostToFacebook] ) {
            text = @"abc";
        }
        else if( [self.activityType isEqualToString:UIActivityTypePostToTwitter] ){
            text = @"cc";
        }

我希望它能对您有所帮助,否则请告诉我.

I hope it helps, if not then let me know.

这篇关于UIActivityViewController Facebook和Twitter共享在已发布的iOS版本中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 04:29