Appstore 作为 iOS6 中的模态视图 [英] Appstore as modal view in iOS6

查看:24
本文介绍了Appstore 作为 iOS6 中的模态视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到当用户点击 iOS6 邮件应用中的应用商店链接时,邮件打开代表应用商店的模态视图,而不是切换到应用商店应用程序就像在以前的版本中一样.

I noticed that when the user taps an app store link in the iOS6 mail app, mail opens a modal view representing the app store instead of switching to the App Store app as it did in previous versions.

Apple 是否提供此功能的访问权限,还是其集成程序独有的功能?

Does Apple provide access to this capability, or it is exclusive to their integrated programs?

注意:如果您有 iOS 6 并且想要测试它,只需打开应用商店并将应用发送给自己.

Note: If you have iOS 6 and want test it, just open appstore and email app to yourself.

推荐答案

我将此方法作为一个类别添加到 UIViewController 中,但您可以根据自己的需要重新调整它的用途.应用商店 ID 是应用商店 URL 中的大数字.确保导入 StoreKit 框架和头文件!

I added this method as a category to UIViewController, but you can repurpose it for your own needs. The app store ID is the big number in the app store URL. Make sure you import the StoreKit framework and header file!

@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]]];
    }
}

这篇关于Appstore 作为 iOS6 中的模态视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆