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
しかし、私は同じ警告を受けました。