我正在使用 UIActionSHeet 从多个共享选项(facebook、twitter、邮件)中进行选择
但是在我选择该选项后,我收到了这个警告
Warning: Attempt to dismiss from view controller <UINavigationController: 0x1ed7eaf0> while a presentation or dismiss is in progress
这是我使用的代码:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
//BOOL displayedNativeDialog;
SLComposeViewController * tw = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
//TWTweetComposeViewController * tw = [[TWTweetComposeViewController alloc]init];
tw.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
[self dismissViewControllerAnimated:YES completion:nil];
};
SLComposeViewController * fb = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
fb.completionHandler = ^(SLComposeViewControllerResult result)
{
[self dismissViewControllerAnimated:YES completion:nil];
};
MFMailComposeViewController * mail = [[MFMailComposeViewController alloc]init];
[mail setMailComposeDelegate:self];
[mail.navigationBar setBackgroundColor:[UIColor blackColor]];
NSData * imageData = [NSData dataWithData:UIImagePNGRepresentation(previewImageView.image)];
switch (buttonIndex) {
case 0:
UIImageWriteToSavedPhotosAlbum(previewImageView.image, nil, nil, nil);
break;
case 1:
[fb addImage:previewImageView.image];
[self presentViewController:fb animated:YES completion:nil];
fb = nil;
break;
case 2:
[actionSheet dismissWithClickedButtonIndex:-1 animated:YES];
[tw addImage:previewImageView.image];
[self presentViewController:tw animated:YES completion:nil];
break;
case 3:
[mail addAttachmentData:imageData mimeType:@"image/png" fileName:@"Image.png"];
[self presentViewController:mail animated:YES completion:nil];
break;
default:
break;
}
}
我也尝试使用委托功能:
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
但我得到了同样的警告。