• iOS调用系统发送短信和邮件分享


    //发送邮件
    -(void)sendMail:(NSString*)subject content:(NSString*)content{
       
       MFMailComposeViewController*controller = [[[MFMailComposeViewControlleralloc]init]autorelease];
       if([MFMailComposeViewControllercanSendMail])
        {
            [controllersetSubject:subject];
            [controllersetMessageBody:contentisHTML:NO];
            controller.mailComposeDelegate=self;
            [selfpresentModalViewController:controlleranimated:YES];
        }
    }
    
    #pragma mark - MFMailComposeViewControllerDelegate
    //邮件完成处理
    -(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{
       
        [selfdismissModalViewControllerAnimated:YES];
       
       if(result ==MessageComposeResultCancelled)
           NSLog(@"Message cancelled");
       elseif(result ==MessageComposeResultSent)
           NSLog(@"Message sent");
       else
           NSLog(@"Message failed"); 
       
    }
    // 发送短信
    - (void)sendSMS:(NSString*)bodyOfMessage recipientList:(NSArray*)recipients
    {
       MFMessageComposeViewController*controller = [[[MFMessageComposeViewControlleralloc]init]autorelease];
       if([MFMessageComposeViewControllercanSendText])
        {
            controller.body= bodyOfMessage;
            controller.recipients= recipients;
            controller.messageComposeDelegate=self;
            [selfpresentViewController:controlleranimated:YEScompletion:^{
               
            }];
        }
    }
    //处理发送完的响应结果
    - (void)messageComposeViewController:(MFMessageComposeViewController*)controller didFinishWithResult:(MessageComposeResult)result
    {
        [selfdismissModalViewControllerAnimated:YES];
       
       if(result ==MessageComposeResultCancelled)
           NSLog(@"Message cancelled");
       else if(result ==MessageComposeResultSent)
           NSLog(@"Message sent");
       else
           NSLog(@"Message failed");
    }
  • 相关阅读:
    ICO图标的制作、下载
    网页Loading,让页面加载完再显示
    鹏城之行
    The shit live,learn to give up!
    缘分
    一篇网络文章,能否让我真正顿悟???
    李开复给中国学生的第三封信:成功、自信、快乐
    Uncountable missing,missing...
    李开复给中国学生的第五封信:做个积极主动的你
    李开复给中国学生的第四封信:大学应这样过
  • 原文地址:https://www.cnblogs.com/ios-wmm/p/10215793.html
Copyright © 2020-2023  润新知