2014-12-05 43 views
0

enter image description here我在iphone上實現twitter上的href鏈接共享..我使用社交共享框架.. 我已經使用下面的代碼爲href url ..但不能發佈href url在Twitter上 NSString * ss = @「http://www.w3schools.com/html>訪問我們的HTML教程」; [twComposer addURL:[NSURL URLWithString:ss]];分享來自iphone的twitter上的href鏈接

  [twComposer setCompletionHandler:completionHandler]; 
      [self presentViewController:twComposer animated:YES completion:nil]; 

能否請你幫我出

回答

0

您可以發佈一個鏈接使用下面的函數嘰嘰喳喳:

- (IBAction)postToTwitter:(id)sender { 
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { 
     SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; 

     [controller setTitle:@"Tweet from My Application"]; 

     NSString *strLink = [NSString stringWithFormat:@" Please refer link http://www.w3schools.com/html Visit our HTML tutorial "]; 

     [controller setInitialText:strLink]; 

     [self presentViewController:controller 
          animated:YES completion:nil]; 

     SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){ 
      if (result == SLComposeViewControllerResultCancelled) { 
       NSLog(@"cancel twitter"); 
      } else { 
       NSLog(@"post twitter"); 
      } 
     }; 
     controller.completionHandler = myBlock; 
    } 
} 

見我編輯的代碼!

希望這有助於... 一切順利!

+0

謝謝......但我想分享這種網址NSString * ss = @「http://www.w3schools.com/html>訪問我們的HTML教程」; [twComposer addURL:[NSURL URLWithString:ss]]; – JohnWhite 2014-12-05 09:53:25

+0

U現在可以檢查方法..它現在將按照您的要求顯示URL ... – 2014-12-05 10:20:00

+0

您可以檢查我編輯的答案嗎? – 2014-12-05 10:28:56