5
A
回答
3
在Apple文檔中,您會發現SLComposeViewController具有完成處理程序屬性而不是委託。你只需要使用setCompletionHandler方法來設置該屬性。然後,您使用常量SLComposeViewControllerResult來恢復帖子是發佈還是取消,並據此採取相應措施。
-(void) shareToFacebook {
//1. Set link and image
NSString *appLink = @"https://itunes.apple.com/app/id989793966";
UIImage *twitterImage = [UIImage imageNamed:@"TF_400x400.png"];
//2. Check if we can share
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
//3. Compose the share view controller
SLComposeViewController *FBViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[FBViewController addURL:[NSURL URLWithString:appLink]];
[FBViewController addImage:twitterImage];
//4 Set completion handler and define actions to take
[FBViewController setCompletionHandler:^(SLComposeViewControllerResult result)
{
if (result == SLComposeViewControllerResultCancelled) {
[self addEmptyScreenButtonTargets];
} else if (result == SLComposeViewControllerResultDone) {
//Unlock words; show thank you screen
[NewCardManager unlockWordsForPackage:4];
[self openFBThankYouScreen];
}
}];
//5. Call to modally present the share controller
[self presentViewController:FBViewController animated:YES completion:nil];
}
}
相關問題
- 1. 沒有委託
- 2. 有沒有更好的方法?委託 - >委託 - >委託
- 3. 爲什麼聯繫委託沒有在SceneKit中調用?
- 4. 爲什麼BCL中沒有EventHandler <TSender,TEventArgs>委託?
- 5. 爲什麼沒有參數的委託會被編譯?
- 6. 沒有超載匹配委託..爲什麼?
- 7. 爲什麼我的委託爲空?
- 8. ADBannerView錯誤(沒有委託或委託沒有實現didFailToReceiveAdWithError :)
- 9. 爲什麼Threading.Timer委託失速?
- 10. 爲什麼Math.sin()委託給StrictMath.sin()?
- 11. 爲什麼要使用委託在.net
- 12. 爲什麼委託引用很弱?
- 13. 爲什麼在ruby中使用委託
- 14. 爲什麼NSURLConnection和CAAnimation委託保留?
- 15. 爲什麼委託不起作用?
- 16. 委託沒有被調用
- 17. PushNotifications委託沒有觸發
- 18. UIScrollView委託沒有着火?
- 19. 「應用委託」沒有可見的@interface「...」是什麼意思?
- 20. 爲什麼委託類型是從MulticastDelegate類派生的,爲什麼不直接從委託類派生?
- 21. 設置委託對象中的委託方法沒有響應
- 22. 沒有重載「方法」匹配委託「委託」
- 23. 委託方法沒有被調用,設置委託給自己?
- 24. 什麼是+ =符號稱爲添加多個委託給委託對象?
- 25. 交易中部分受委託和受委託國之間有什麼區別?
- 26. 爲什麼在使用委託方法時沒有選中警告?
- 27. C# - 爲什麼我可以在沒有實例化的類中使用委託?
- 28. 在沒有委託的情況下創建線程 - 爲什麼這可行?
- 29. 爲什麼我的自定義委託方法沒有收到呼叫?
- 30. 爲什麼沒有超重的Distinct()接受比較委託(或類似的)
這就是完成處理程序是什麼。 –
啊,我錯過了。現在他們使用該代替代理。 –