简体   繁体   English

使用iOS 8.4中的社交框架的iOS应用程序中的Twitter和Facebook共享添加URL在Objective C中不起作用

[英]Twitter and Facebook Sharing in iOS application using Social Framework in iOS 8.4 adding URL not working in Objective C

Adding URL in Twitter and Facebook sharing in iOS application using Social framework for iOS 8.4 is not working. 使用iOS 8.4社交框架在iOS应用程序中的Twitter和Facebook共享中添加URL无效。

Only setInitialText: method is working but not the addURL and setTile methods. setInitialText:方法有效,而addURLsetTile方法setTile

My code is as follows: 我的代码如下:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

        SLComposeViewController *fbFeed = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        [fbFeed setInitialText:self.travelogueTitle];
        [fbFeed addURL:[NSURL URLWithString:self.saveTraveloguePublishedURL]];
        [fbFeed setTitle:@"My Trip's Memories"];
        NSLog(@"Save published url:%@",self.saveTraveloguePublishedURL);
        NSLog(@"Share published url:%@",travelogue.publishedUrl);
        // [fbFeed setInitialText:[NSString stringWithFormat:@"http://mvm064/MVPWeb/ViewTravelogue?travelogueId=OB1YlsTz/gngmCUTESuqlQ=="]];

        [fbFeed setCompletionHandler:^(SLComposeViewControllerResult result) {

            if (result == SLComposeViewControllerResultCancelled) {
                    NSLog(@"The user cancelled.");
            }
            else if (result == SLComposeViewControllerResultDone) {
                NSLog(@"The user posted to Facebook");
            }
        }];

        [self presentViewController:fbFeed animated:YES completion:nil];
    }}

There is no method in SLComposeViewController to setTitle . SLComposeViewController没有方法可以设置setTitle SLComposeViewController is basically subclass of UIViewController so giving you facility to set title of SLComposeViewController . SLComposeViewController基本上是UIViewController subclass ,因此为您提供了设置SLComposeViewController标题的SLComposeViewController It will not going to post on Facebook . 它不会在FacebookFacebook For post on Facebook you have method called setInitialText . 要在Facebook发帖,您可以使用名为setInitialText方法。

I have tried with your code and its get uploaded successfully, you can check out in following image. 我已尝试使用您的代码并将其成功上传,您可以在下图中查看。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM