zoukankan      html  css  js  c++  java
  • OC发送短信

    - (IBAction)sendMessage1:(id)sender {
        
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"短信编辑"message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        alert.tag = 1;
        
        alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
        
        UITextField *tf1 = [alert textFieldAtIndex:0];
        tf1.placeholder = @"编辑的短信内容";
        
        UITextField *tf2 = [alert textFieldAtIndex:1];
        tf2.placeholder = @"需要发送到的手机号";
        tf2.secureTextEntry = NO;
        
        [alert show];
        
        
        
        
        
        
    }
    - (IBAction)sendMessage2:(id)sender {
        
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"短信编辑"message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        alert.tag = 2;
        
        
        NSURL *url = [NSURL URLWithString:@"sms://11395320253"];
                      
                      [[UIApplication sharedApplication] openURL:url];
        
        
    }
    
    #pragma mark MFMessageComposeViewControllerDelegate
    // 点击取消按钮会自动调用
    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
        [self dismissViewControllerAnimated:YES completion:nil];
        switch (result) {
            case MessageComposeResultSent:
                //信息传送成功
                
                break;
            case MessageComposeResultFailed:
                //信息传送失败
                
                break;
            case MessageComposeResultCancelled:
                //信息被用户取消传送
                
                break;
            default:
                break;
        }
    
        
    }
    
    
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
        if(buttonIndex != 0){
            return;
        }
        
    
        
        UITextField *tf1 = [alertView textFieldAtIndex:0];
     
        
        UITextField *tf2 = [alertView textFieldAtIndex:1];
    
    
        
        
        
        
        MFMessageComposeViewController *msgVc = [[MFMessageComposeViewController alloc] init];
        // 设置短信内容
        msgVc.body = tf1.text;
        // 设置收件人列表
        msgVc.recipients = @[tf2.text];
        // 设置代理
        msgVc.messageComposeDelegate = self;
        // 显示控制器
        [self presentViewController:msgVc animated:YES completion:nil];
        
        
        
    }
    
  • 相关阅读:
    覆盖一个DIV,让radio、checkbox和select只读
    DNN 配置 数据库篇
    Javascript实用语句收录
    绑定Hashtable到DataList
    WebDeploymentSetup 合并程序集时出错(ILMerge.Merge: ERROR)
    只能向页面中添加 ScriptManager 的一个实例
    让DNN添加的别名起作用
    360极速模式(Chrome内核)下由ashx输出的JavaScript代码不起作用
    C#中常用到的时间函数(天数差、星期几等)
    C#实用语句
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/7196123.html
Copyright © 2011-2022 走看看