在程序中实现邮件发送,电话拨打,sms,以及浏览器功能能的方法:
邮件
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
电话
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
sms
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];
浏览器
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunesconnect.apple.com"]];
**********************************************************************************
在程序中实现电话的拨打:
//[font="]添加电话图标按钮
UIButton*btnPhone = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
btnPhone.frame = CGRectMake(280,10,30,30);
UIImage *image = [UIImage imageNamed:@"phone.png"];
[btnPhone setBackgroundImage:image forState:UIControlStateNormal];
//[font="]点击拨号按钮直接拨号 [font="]
[btnPhone addTarget:self action:@selector(callAction:event:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:btnPhone]; //cell[font="]是一个UITableViewCell
//[font="]定义点击拨号按钮时的操作 [font="]
- (void)callAction:(id)sender event:(id)event{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.listTable];
NSIndexPath*indexPath=[self.listTable indexPathForRowAtPoint:currentTouchPosition];
if (indexPath == nil){
return;
}
NSInteger section = [indexPath section];
NSUInteger row = [indexPath row];
NSDictionary *rowData = [datas objectAtIndex:row];
NSString *num = [[NSString alloc] initWithFormat:@"tel://%@",number]; //number[font="]为号码字符串
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //[font="]拨号
}
打完电话回不去的话,就用@"telprompt://123456"就好了。