我试图在推特发布成功完成后呈现模态视图;然而,我无法展示我的控制器,因为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>
我使用completionHandler,但问题是,SLComposeViewController仍然被提出时,完成处理器上运行,所以提出另一种看法控制器出现故障。 – steventnorris 2014-09-03 14:08:54
你必须首先关闭'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
“在iOS 7及更高版本中,当使用iOS 7或更高版本的SDK编译时,您不得在完成处理程序中关闭SLComposeViewController,系统将自动执行此操作。我正在为iOS 7编码。 – steventnorris 2014-09-03 17:28:38