iTa*_*rek 22 xcode app-store ios6
我注意到当用户点击iOS6邮件应用程序中的应用程序商店链接时,邮件会打开一个代表应用程序商店的模态视图,而不是像之前版本中那样切换到App Store应用程序.
Apple是否提供对此功能的访问权限,或者它是否为其集成程序所独有?
注意:如果你有iOS 6并想要测试它,只需打开appstore和电子邮件应用程序给自己.
Max*_*iel 44
我将此方法作为类别添加到UIViewController,但您可以根据自己的需要重新调整它.应用商店ID是应用商店网址中的大号码.确保导入StoreKit框架和头文件!
@import StoreKit;
- (void)presentAppStoreForID:(NSNumber *)appStoreID withDelegate:(id<SKStoreProductViewControllerDelegate>)delegate
{
if(NSClassFromString(@"SKStoreProductViewController")) { // Checks for iOS 6 feature.
SKStoreProductViewController *storeController = [[SKStoreProductViewController alloc] init];
storeController.delegate = delegate; // productViewControllerDidFinish
// Example App Store ID (e.g. for Words With Friends)
// @322852954
[storeController loadProductWithParameters:@{ SKStoreProductParameterITunesItemIdentifier: appStoreID }
completionBlock:^(BOOL result, NSError *error) {
if (result) {
[self presentViewController:storeController animated:YES completion:nil];
} else {
[[[UIAlertView alloc] initWithTitle:@"Uh oh!" message:@"There was a problem opening the app store" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil] show];
}
}];
} else { // Before iOS 6, we can only open the App Store URL
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/app/id%@",appStoreID]]];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9140 次 |
| 最近记录: |