- Launch the Browser
- Launch Google Maps
- Launch Apple Mail
- Dial a Phone Number
- Launch the SMS Application
- Launch the AppStore
아래는 URL을 open함으로써 다른 App을 띄우는데, iPod에서는 Call과 SMS 관련 App을 띄울 수 없을 것이다. 이 경우 openURL 함수의 return 값을 체크 (못 띄우는 경우 NO 반환) 할 수 있을 것이다.
2
| [[UIApplication sharedApplication] openURL:url];
|
2. Launch Google Maps
아래와 같이 QUERY_STRING에 원하는 검색 string을 넣어서 URL을 launch해준다.
http://maps.google.com/maps?q=${QUERY_STRING}
02
| NSString* searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";
|
05
| searchQuery = [addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
|
11
| [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
|
mailto://에 email address를 넣어주면 된다.
mailto://${EMAIL_ADDRESS}
1
| [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:
|
4-1. URL을 open하는 방식은 아래와 같이 tel: 뒷 부분에 번호를 쓰면 된다.
1
| [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]]; |
아래와 같이 웹 페이지를 통해서 콜을 부를 수도 있다.
아래와 같은 내용을 가진 about.txt가 있다고 할 때,
applicationDidFinishLoading에서 WebView를 만들고 이것을 window에 add하는 코드는 아래와 같다.
01
| - (void)applicationDidFinishLaunching:(UIApplication *)application
|
03
| window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
07
| [[UIWebView alloc] initWithFrame:CGRectMake(0, 20, 320, 35)];
|
08
| webView.backgroundColor = [UIColor whiteColor];
|
09
| [webView setOpaque:NO];
|
12
| NSString *textpath = @"about.txt";
|
14
| [[NSBundle mainBundle] pathForResource:textpath ofType:nil];
|
15
| NSString *html = [NSString stringWithContentsOfFile:filePath];
|
18
| NSString *htmlOpen = @"";
|
19
| NSString *htmlClose = @"";
|
23
| [NSString stringWithFormat:@"%@ %@ %@", htmlOpen, html, htmlClose];
|
26
| [webView loadHTMLString:bodyhtml baseURL:nil];
|
29
| [window addSubview:webView];
|
34
| [window makeKeyAndVisible];
|
5. Launch the SMS Application
sms:${PHONENUMBER_OR_SHORTCODE}
1
| [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:55555"]];
|
6. Launching App’s page in AppStore
위 코드에서 띄우고 싶은 App을 App Store에서 찾아서 app 의 url을 복사 후 id부분을 써주면 된다.
(iTunes App Sotre의 App URL (http://itunes.XXX 로 시작하는)을 그대로 띄우면 안된다.)
댓글 없음:
댓글 쓰기