邮件和邮件不会从警报视图中撤销 [英] Mail and Message not Dismissing from Alert View

查看:115
本文介绍了邮件和邮件不会从警报视图中撤销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIAlertView启动一个电子邮件和一个消息屏幕。当用户点击警报的按钮时,这两个视图都会打开,但是它们不会关闭。



我尝试添加:


$ (MFMailComposeViewController *)控件didFinishWithResult:(MFMailComposeResult)结果错误:(NSError *)错误{
[self dismissModalViewControllerAnimated:YES] ;
}

到该类的正文,但是没有帮助。 p>

这是电子邮件的显示方式:

  [viewController presentViewController:email动画:YES完成:nil]; 

编辑这是我用来显示电子邮件的整个代码:

  //发送电子邮件... 
- (void)sendEmail {

/ / mail composer
Class mailClass =(NSClassFromString(@MFMailComposeViewController));
if(mailClass!= nil){
if([mailClass canSendMail]){

//从App代理获取当前视图控制器
apptester_appDelegate * appDelegate =(apptester_appDelegate *)[[UIApplication sharedApplication] delegate];
UIViewController * viewController = [appDelegate getViewController];

MFMailComposeViewController * email = [[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;

//导航栏颜色取决于iOS7或更低版​​本...
if(floor(NSFoundationVersionNumber)< = NSFoundationVersionNumber_iOS_6_1){
[[email navigationBar] setTintColor:[UIColor黑色];
} else {
[[email navigationBar] setBarTintColor:[UIColor blackColor]];
}

//显示模型视图...
[viewController presentViewController:电子邮件动画:YES完成:nil];

}
}
}

有没有人否则会出现此错误?



这可能并不相关,但这个应用程序有一个标签栏。

解决方案

确保已设置邮件控制器委托人

  mail.mailComposeDelegate = viewController; 

另请尝试,

  [viewController.tabBarController presentViewController:email animated:YES completion:nil]; 

您是否尝试使用此方法并传递控制器而不是self:

$ b $ (MFMailComposeViewController *)控制器didFinishWithResult:(MFMailComposeResult)结果错误:(NSError *)错误
{
[controller dismissViewControllerAnimated:YES completion:nil];
}

谢谢!


I have a UIAlertView that launches an email and a messages screen. When a user clicks on the Alert's button, both views open, however, they do not close.

I have a tried adding:

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    [self dismissModalViewControllerAnimated:YES];
}

to the body of the class, however, it did not help.

Here is how the email is presented:

    [viewController presentViewController:email animated:YES completion:nil];

Edit Here is the entire code I am using to present the email:

//send email...
-(void)sendEmail{

    //mail composer
    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if(mailClass != nil){
        if([mailClass canSendMail]){

            //get the current view controller from the App Delegate
            apptester_appDelegate *appDelegate = (apptester_appDelegate *)[[UIApplication sharedApplication] delegate];
            UIViewController *viewController = [appDelegate getViewController];

            MFMailComposeViewController *email = [[MFMailComposeViewController alloc] init];
            email.mailComposeDelegate = self;

            //navigation bar color depends on iOS7 or lower...
            if(floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1){
                [[email navigationBar] setTintColor:[UIColor blackColor];
            }else{
                [[email navigationBar] setBarTintColor:[UIColor blackColor]];
            }

            //show the model view...
            [viewController presentViewController:email animated:YES completion:nil];

        }
    }
}

Has anyone else experienced this error?

This may not be relevant, but this app has a tab bar.

解决方案

Make sure you have set delegate for mail controller

   mail.mailComposeDelegate = viewController;

Also try this as well,

    [viewController.tabBarController presentViewController:email animated:YES completion:nil];

Have you try this method and pass "controller" instead of self:

   -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
    {
       [controller dismissViewControllerAnimated:YES completion:nil];
    }

Thanks!

这篇关于邮件和邮件不会从警报视图中撤销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆