簡體   English   中英

當我使用發布通知時,社交框架的取消按鈕不隱藏控制器,而是隱藏警報

[英]When I use Post Notification then cancel button of Social framework don't hide Controller but hides alert

我正在使用社交框架進行共享。在共享按鈕的IBAction中,我發布了通知。但是,當我按特定社交網站的“設置”警報的“取消”按鈕時,警報隱藏,但鍵盤和控制器沒有隱藏。 我正在使用以下代碼

- (IBAction)shareOnFB:(id)sender
{
    [[NSNotificationCenter defaultCenter]postNotificationName:@"hideNotification" object:nil];
    SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    [controllerSLC setInitialText:_dictShare[@"description"]];
    [controllerSLC addURL:[NSURL URLWithString:@"http://www.appcoda.com"]];
    //    [controllerSLC addImage:[UIImage imageNamed:@"test.jpg"]];
    [self presentViewController:controllerSLC animated:YES completion:Nil];

}

提前致謝。

我自己解決了。您必須使用以下代碼設置它的完成。

介紹控制器后只需添加以下代碼

[controllerSLC setCompletionHandler:^
 (SLComposeViewControllerResult result) {

     [[NSNotificationCenter defaultCenter]postNotificationName:@"hideNotification" object:nil];

     NSString *output = [[NSString alloc] init];


     switch (result) {
         case SLComposeViewControllerResultCancelled:
             output = @"Post Cancelled";
             break;
         case SLComposeViewControllerResultDone:
             output = @"Posted successfully";
             break;

         default:
             break;
     }
 }];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM