iOS 從app跳轉到Safari、從app打開電話呼叫

1.從app跳轉到Safariweb

1 NSString* strIdentifier = @"http://www.ybyb.com";
2             BOOL isExsit = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:strIdentifier]];
3             if(isExsit) {
4                 NSLog(@"App %@ installed", strIdentifier);
5                 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:strIdentifier]];
6             }

 

2.從app打開電話呼叫app

 1  NSString *phoneNum = @"10086";// 電話號碼
 2         
 3         UIWebView *phoneCallWebView;
 4         NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNum]];
 5          if ( !phoneCallWebView ) {
 6         phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];// 這個webView只是一個後臺的View 不須要add到頁面上來
 7             
 8              }
 9         [phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
10         
11         [self.view addSubview:phoneCallWebView];
相關文章
相關標籤/搜索