苹果商店在iOS6的模式视图 [英] Appstore as modal view in iOS6

查看:158
本文介绍了苹果商店在iOS6的模式视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当用户点击了iOS6的邮件应用应用商店的链接,邮件的打开一个模态视图重新presenting应用商店而不是切换为它在previous版本做了App Store应用。

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.

苹果是否提供获得这种能力,或者是独家的综合方案?

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

注意:如果您有iOS 6中,想测试它,只需打开AppStore的和电子邮件应用程序自己

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

推荐答案

我添加了这个方法,一个类别的UIViewController,但你可以将其用于自己的需要。 App Store的ID是在App Store 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]]];
    }
}

这篇关于苹果商店在iOS6的模式视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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