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];
}
}