iOS6.0 新功能:在应用程序内展示App Store
#import
2、在需要点击事件中,添加代码,如下:
– (IBAction)gotoStore:(id)sender {
// Initialize Product View Controller
SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];
// Configure View Controller
[storeProductViewController setDelegate:self];
[storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @”594467299″}
completionBlock:^(BOOL result, NSError *error) {
if (error) {
NSLog(@”Error %@ with User Info %@.”, error, [error userInfo]);
} else {
// Present Store Product View Controller
[self presentViewController:storeProductViewController animated:YES completion:nil];
}
}];
}
3、设置协议 SKStoreProductViewControllerDelegate,并且实习协议中的方法,如下:
– (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController __OSX_AVAILABLE_STAR