跳转safari
NSURL* urls = [[NSURL alloc] initWithString:dataDic[@"data"]];
[[UIApplication sharedApplication] openURL:urls];
拨号功能
方法一:
// 直接进入播号界面
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];
方法二:
NSMutableString *str = [[NSMutableString alloc] initWithFormat: @"tel:%@", self.phone];
static UIWebView *webView = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
webView = [UIWebView new];
});
[webView loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString: str]]];
[self.view addSubview: webView];
发送短信
方法一:调出发送短信页面
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms://10000"]];
方法二:带有短信内容(导入MessageUI.framework)
#import <MessageUI/MessageUI.h>
- (void)sendMessage {
[self showMessageView:[NSArray arrayWithObjects:@"10086", nil nil] title:@"test" body:@"abc"];
}
-(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]; //修改短信界面标题
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示信息"
message:@"该设备不支持短信功能"
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil, nil];
[alert show];
}
}
#pragma mark - MFMessageComposeViewController
-(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;
}
}
发送微信(Umeng接口)
#import "UMSocial.h"
- (void)sendMesgByWeChat {
[UMSocialData defaultData].extConfig.wechatSessionData.title = @" ";
[UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeText;
// UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeImage url:nil];
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToWechatSession]
content:_messageTextView.text
image:nil
location:nil
urlResource:nil
presentedController:self
completion:^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
KTLog(@"发送成功!");
}
}];
}