1.调用设备浏览器
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.baidu.com"]];
2.设备的拨号功能
-(void)gotoPhone{
//判断能否打电话
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType containsString:@"iPod touch"]||[deviceType containsString:@"iPad"]||[deviceType containsString:@"iPhone Simulator"]){
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"您的设备无法拨号" delegate:nil cancelButtonTitle:@"好的,知道了" otherButtonTitles:nil,nil];
[alert show];
}else{
//拨号的方法
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",PhoneNumber ]]];
}
}
3.判断邮箱格式是否正确的代码:
//利用正则表达式验证
-(BOOL)isValidateEmail:(NSString *)email
{
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailRegex];return [emailTest evaluateWithObject:email];
}```
4.调用QQ
import "WXApi.h" //调用微信时添加
import //调用QQ的时候引入
- (void)gotoQQ
{
if ([QQApi isQQInstalled]) {//判断是否安装QQ
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web", CustomerServiceQQ]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
// webView.delegate = self;
[webView loadRequest:request];
[self.view addSubview:webView];
}
}
网友评论