2016-06-10 66 views
0

我有以下代碼:SLComposeViewController SLServiceTypeFacebook不工作的iOS 9.1

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 
    SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){ 
    if (result == SLComposeViewControllerResultCancelled) 
     NSLog(@"Cancelled"); 
    else 
     NSLog(@"Done"); 

    [controller dismissViewControllerAnimated:YES completion:Nil]; 
    }; 
    controller.completionHandler = myBlock; 
    [controller setInitialText:@"blah blah"]; 

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

我已經跨越>的iOS版本8.x的嘗試,但是,我發現只有在iOS 9.1中,Post按鈕是灰色和文本字段爲空,而在較新的iOS版本9.3.1中則不是。

有人有想法嗎?我懷疑,因爲這樣:

插件com.apple.share.Facebook.post無效

這導致我link發現,Facebook的政策不允許預填充的文字,但爲什麼在iOS 9.3.1的作品。

更新: 我在文本字段中鍵入一些文本後再次啓用「發佈」按鈕。

+0

回覆您的更新,可以不再重現該問題在你的問題? – JAL

+0

其實,我想知道爲什麼'initialText'只適用於iOS 9.1 – Rendy

回答

-1

試試這個代碼

if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) 
{ 
    let twitterComposeVC = SLComposeViewController(forServiceType: SLServiceTypeFacebook) 
    twitterComposeVC.setInitialText(messagge) 
    twitterComposeVC.addURL(NSURL.init(string: url)) 

    fromController.presentViewController(twitterComposeVC, animated: true, completion: nil) 
} 
else 
{ 
    print("No twitter account is configured in settings."); 
} 
+0

我的代碼和你完全一樣 – Rendy