iOS开发-从app跳转到第三方应用和调用系统功能

//跳转到QQ客户端的相应聊天界面

- (IBAction)ToQQ:(UIButton *)sender {

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];

NSURL *url = [NSURL URLWithString:@"mqq://im/chat?chat_type=wpa&uin=942043611&version=1&src_type=web"];

NSURLRequest *request = [NSURLRequest requestWithURL:url];

webView.delegate = self;

[webView loadRequest:request];

[self.view addSubview:webView];

}

2.调用系统打电话功能。(调用打电话功能有两种)

*1*:

//调用系统打电话功能,结束后返回应用。(会有弹窗提醒,点击呼叫后才可进行呼叫,手机号自己替换)

- (IBAction)ToCall:(id)sender {

//打电话的方法

UIWebView *callWebView = [[UIWebView alloc] init];

NSURL *telURL = [NSURL URLWithString:@"tel:13299437022"];

[callWebView loadRequest:[NSURLRequest requestWithURL:telURL]];

[self.view addSubview:callWebView];

}

*2*:

//调用系统打电话功能.结束后返回应用。(没有弹窗提醒,直接呼叫,手机号自己替换)

- (IBAction)ToCall2:(id)sender {

NSString *allString = [NSString stringWithFormat:@"tel:13299437022"];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:allString]];

}

3.发送短信功能。

//发送短信  (“10086”表示接收方)

- (IBAction)sendSMS:(id)sender {

UIApplication *app = [UIApplication sharedApplication];

[app openURL:[NSURL URLWithString:@"sms://10086"]];

}

4.发送邮件(调用iPhone自带邮箱)

//发邮件 (自带邮箱)

- (IBAction)sendEmil:(id)sender {

UIApplication *app = [UIApplication sharedApplication];

[app openURL:[NSURL URLWithString:@"mailto://[email protected]"]];

}

5.跳转到到系统设置界面

//跳转到到系统设置界面

- (IBAction)ToSetting:(id)sender {

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

if ([[UIApplication sharedApplication] canOpenURL:url]) {

[[UIApplication sharedApplication] openURL:url];

}

}

6.跳转到系统设置里的定位服务

//跳转到系统设置里的定位服务

- (IBAction)Localcation:(id)sender {

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];

}

7.跳转到WiFi设置界面

//WiFi

- (IBAction)ToWifi:(id)sender {

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];

}

你可能感兴趣的:(OC,基础数据,ios,ios开发,objective-c)