소개
아시는 분들은 아시겠지만 iOS 6.0부터 지원되는 것이라 모르시는 분들이 많은 것 같습니다.
아래 그림1을 보시면 현재 회사에서 소개하고 싶은 여러 앱들이 있습니다.
보통 누르면 나의 앱에서 빠져나가고 앱스토어 앱으로 이동합니다.
다른 앱으로 나가는게 썩 보기 좋지 않았었는데, 이제 그런 고민 하지 않아도 될 것 같습니다.

변경후,
그림2처럼 iOS6부터는 앱 자체적으로 불러들일 수 있습니다.
SKStoreProductViewController 컨트롤러가 생겼기때문이죠!

사용방법
그림2와 같이 집어 넣으니 이동을 하지 않아서 너무 좋더군요!
우선 <StoreKit.framework>을 프로젝트로 추가해주신 후, 다음과 같이 코드를 작성해주세요!
일반적인 뷰컨트롤러 호출 방식과 동일합니다.
1
2
3
4
5
6
7
8
9
10
11
12
|
#import <StoreKit/StoreKit.h>
SKStoreProductViewController *viewController = [[SKStoreProductViewController alloc] init];
[viewController setDelegate:self];
[viewController loadProductWithParameters:[NSDictionary dictionaryWithObjectsAndKeys:appId, SKStoreProductParameterITunesItemIdentifier, nil] completionBlock:^(BOOL result, NSError *error) {
if (result) {
[self presentViewController:viewController animated:YES completion:nil];
} else {
// 에러 처리
}
}];
[viewController release];
|
딜리게이트도 있는데요!! 해당 헤더에 SKStoreProductViewControllerDelegate 선언해주시고!
아래와 같이 창을 닫도록 처리해주시면 됩니다.
1
2
3
4
|
– (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
[viewController dismissViewControllerAnimated:YES completion:nil];
}
|