0

我试图在推特发布成功完成后呈现模态视图;然而,我无法展示我的控制器,因为SLComposeViewController仍在呈现。是否有一些完成方法会在所有事件都发生竞争并且视图被解散时调用?当前视图控制器完成Twitter的呼叫

SLComposeViewController* tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; 
    tweetSheet.completionHandler = ^(SLComposeViewControllerResult result){ 
     UBSTwitterSuccessViewController* twitterView; 
     switch(result){ 
      case SLComposeViewControllerResultCancelled: 
       break; 
      case SLComposeViewControllerResultDone: 
       twitterView = [[UBSTwitterSuccessViewController alloc]initWithNibName:XIBTWITTERSUCCESS bundle:nil]; 
       [self presentViewController:twitterView animated:YES completion:nil]; 
       break; 
     } 
    }; 
    [tweetSheet setInitialText:@"Check out this cool thing"]; 
    [tweetSheet addURL: [NSURL URLWithString:@"http://www.cad-comic.com/"]]; 

    [self presentViewController:tweetSheet animated:NO completion:nil]; 

没有呈现视图警告:

Warning: Attempt to present <UBSTwitterSuccessViewController: 0x16569b70> on <UINavigationController: 0x1663bd30> which is already presenting <SLComposeViewController: 0x166b1170> 

回答

-1

SLComposeViewController在对其分配块completionHandler当用户完成或取消的组成后执行。

completionHandler用户完成撰写文章 后调用的处理函数。

@属性(非原子,副本)SLComposeViewControllerCompletionHandler completionHandler讨论处理程序有一个单一的参数 指示用户是否完成或取消撰写的文章。 该块不保证在任何特定的线程上被调用。

特别注意事项在iOS 6中和更早的版本,如果你设置完成 处理器那么你完成处理程序是负责使用 dismissViewControllerAnimated驳回 SLComposeViewController:完成:.在iOS 7及更高版本中,当使用iOS 7或更高版本SDK编译 时,您不得在完成处理程序中关闭 SLComposeViewController - 系统将自动执行 。

Apple Documentation

+0

我使用completionHandler,但问题是,SLComposeViewController仍然被提出时,完成处理器上运行,所以提出另一种看法控制器出现故障。 – steventnorris 2014-09-03 14:08:54

+1

你必须首先关闭'tweetSheet'。 'case SLComposeViewControllerResultDone: [self dismissViewControllerAnimated:YES completion:^ {0} {[UBSTwitterSuccessViewController alloc] initWithNibName:XIBTWITTERSUCCESS bundle:nil]; [self presentViewController:twitterView animated:YES completion:nil]; }];' – 2014-09-03 16:12:33

+0

“在iOS 7及更高版本中,当使用iOS 7或更高版本的SDK编译时,您不得在完成处理程序中关闭SLComposeViewController,系统将自动执行此操作。我正在为iOS 7编码。 – steventnorris 2014-09-03 17:28:38