106 系統自帶分享

1.首先導入Social/Social.h框架,然後執行以下代碼:

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) {
        NSLog(@"分享可用");
    }

    SLComposeViewController *vc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];

    [vc setInitialText:@"hahahaha"];
    //可以添加圖片
//    [vc addImage:[UIImage imageNamed:@""]];
    [self presentViewController:vc animated:YES completion:nil];

    vc.completionHandler = ^(SLComposeViewControllerResult result){
        if (result == SLComposeViewControllerResultCancelled) {
            NSLog(@"quxiao");
        }else{
            NSLog(@"wancheng");
        }
    };
}
發佈了124 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章