IPhone之发送短信

来源:互联网 发布:哪里可以买到客户数据 编辑:程序博客网 时间:2024/05/19 13:45
原文地址:IPhone之发送短信作者:飞舞的鸡毛
首先继承 MFMessageComposeViewControllerDelegate协议
实现代码:
 

if([[UIDevice currentDevice].systemVersion floatValue] >= 4.0){

if([MFMessageComposeViewControllercanSendText]){

MFMessageComposeViewController *controller =[[MFMessageComposeViewController alloc]init];

controller.messageComposeDelegate= self;

controller.recipients = [NSArray arrayWithObject:selectedUser.mobileTel_default];

[self presentModalViewController:controller animated:YES];

[controller release];

}else{

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"出错了"message:@"您的设备不能发送短信"delegate:nil cancelButtonTitle:@"好的" otherButtonTitles:nil];

[alert show];

[alert release];

}

}else {

[[UIApplication sharedApplication] openURL:[NSURLURLWithString:[NSString stringWithFormat:@"sms://",selectedUser.mobileTel_default]]];

}





 

- (void)messageComposeViewController:(MFMessageComposeViewController*)controller didFinishWithResult:(MessageComposeResult)result{

if (result ==MessageComposeResultSent) {

[selfdismissModalViewControllerAnimated:YES];

}else {

//failedto send text msg

}


}


原创粉丝点击