외규장각 도서 환수 모금 캠페인

'2013/10/11'에 해당되는 글 1건

  1. 2013.10.11 앱 안에서 앱스토어 띄우기
1. StoreKit.framework 라이브러리를 추가해줍니다 
2. 헤더파일에 #import <StoreKit/SKStoreProductViewController.h>를 추가합니다
3. SKStoreProductViewControllerDelegate 델리게이트를 추가해줍니다

[self presentAppStoreForID:[NSNumber numberWithInt:앱아이디inView:띄울 부모뷰(self.view) withDelegate:self withURL:[NSURLURLWithString:iOS6 이전 버전에 사용할 앱스토어 링크]];



- (void)presentAppStoreForID:(NSNumber *)appStoreID inView:(UIView *)view withDelegate:(id<SKStoreProductViewControllerDelegate>)delegate withURL:(NSURL *)appStoreURL

{

    if(NSClassFromString(@"SKStoreProductViewController")) { // iOS6 이상인지 체크


        SKStoreProductViewController *storeController = [[SKStoreProductViewController allocinit];

        storeController.delegate = delegate; // productViewControllerDidFinish


        NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier : appStoreID };



        [storeController loadProductWithParameters:productParameters completionBlock:^(BOOL result, NSError *error) {

            if (result) {

                [self presentViewController:storeController animated:YES completion:nil];

            } else {

                [[[UIAlertView allocinitWithTitle:@"연결 실패" message:@"앱을 불러올  없습니다." delegate:nil cancelButtonTitle:@"확인"otherButtonTitlesnil] show];

            }

        }];

    } else { // iOS6 이하일 

        [[UIApplication sharedApplicationopenURL:appStoreURL];

    }

}


// 닫을 때 

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {

    [viewController dismissModalViewControllerAnimated:YES];

}


Posted by 닉네임영역
,


사랑합니다. 편안히 잠드소서