撥打電話
1摄咆,這種方法凡蚜,撥打完電話回不到原來的應(yīng)用人断,會停留在通訊錄里,而且是直接撥打朝蜘,不彈出提示恶迈。
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxx6979"];
// NSLog(@"str======%@",str);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
2,這種方法谱醇,打完電話后還會回到原來的程序暇仲,也會彈出提示,推薦這種副渴。
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxx6979"];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
[self.view addSubview:callWebview];
[callWebview release];
[str release];
3,這種方法也會回去到原來的程序里(注意這里的telprompt)奈附,也會彈出提示。
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"186xxxx6979"];
//NSLog(@"str======%@",str);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
發(fā)送短信
- 程序外調(diào)用系統(tǒng)發(fā)短信
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms://13888888888"]];
- 程序內(nèi)調(diào)用系統(tǒng)發(fā)短信
1)導(dǎo)入MessageUI.framework煮剧,并引入頭文件:
#import <MessageUI/MessageUI.h>
2)實(shí)現(xiàn)代理方法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;
}
}
3)發(fā)送短信
-(void)showMessageView:(NSArray *)phones title:(NSString *)title body:(NSString *)body
{
if( [MFMessageComposeViewController canSendText] )
{
MFMessageComposeViewController * controller = [[MFMessageComposeViewController alloc] init];
controller.recipients = phones;
controller.navigationBar.tintColor = [UIColor redColor];
controller.body = body;
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
[[[[controller viewControllers] lastObject] navigationItem] setTitle:title];//修改短信界面標(biāo)題
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示信息"
message:@"該設(shè)備不支持短信功能"
delegate:nil
cancelButtonTitle:@"確定"
otherButtonTitles:nil, nil];
[alert show];
}
}
參數(shù)phones:發(fā)短信的手機(jī)號碼的數(shù)組斥滤,數(shù)組中是一個(gè)即單發(fā),多個(gè)即群發(fā)将鸵。
4)調(diào)用發(fā)短信的方法
[self showMessageView:[NSArray arrayWithObjects:@"13888888888",@"13999999999", nil] title:@"test" body:@"你是土豪么,么么噠"];