xcode Appstore 作为 iOS6 中的模态视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12475568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:30:59  来源:igfitidea点击:

Appstore as modal view in iOS6

xcodeapp-storeios6

提问by iTarek

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

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

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

Apple 是否提供对这种功能的访问,或者它是其集成程序所独有的?



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

注意:如果你有 iOS 6 并且想要测试它,只需打开 appstore 和电子邮件应用程序给自己。

回答by MaxGabriel

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!

我将此方法作为一个类别添加到 UIViewController,但您可以根据自己的需要重新调整它的用途。应用商店 ID 是应用商店 URL 中的大数字。确保导入 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]]];
    }
}

回答by alphageek

Looks like this is introduced in IOS 6 as StoreKit, specifically SKITunesProductViewControllerwhich allows you to present iTunes contents (apps, music, books etc.) inside your app for user to purchase directly.

看起来这是在 IOS 6 中作为 StoreKit 引入的,特别是SKITunesProductViewController,它允许您在您的应用程序中呈现 iTunes 内容(应用程序、音乐、书籍等)以供用户直接购买。

回答by Pete

There is a plugin for handling affiliate links here: https://github.com/adeven/AEProductController

这里有一个用于处理附属链接的插件:https: //github.com/adeven/AEProductController

Or you could roll your own by first opening the affiliate link in-app (just as you would before opening the iTunes Store app directly), following the Apple Technical Q&A QA1629:

或者,您可以按照 Apple 技术问答 QA1629 首先打开应用程序内的附属链接(就像您在直接打开 iTunes Store 应用程序之前所做的那样)来推出自己的链接:

https://developer.apple.com/library/ios/#qa/qa2008/qa1629.html

https://developer.apple.com/library/ios/#qa/qa2008/qa1629.html

and then opening the SKStoreProductViewController as MaxGabriel noted above.

然后像上面提到的 MaxGabriel 一样打开 SKStoreProductViewController。

[Edit] I completed this in my app (a music app) but whether I have an active AVAudioSession or I completely disable all playback (for testing), song samples in the modal iTunes Store play but have no sound. If you don't have this issue or you find a resolution, let me know. It may be a bug that should be reported to https://bugreport.apple.com/.

[编辑] 我在我的应用程序(一个音乐应用程序)中完成了这个,但是无论我有一个活动的 AVAudioSession 还是我完全禁用所有播放(用于测试),模式 iTunes Store 中的歌曲样本播放但没有声音。如果您没有遇到此问题或找到了解决方案,请告诉我。这可能是一个应该报告给https://bugreport.apple.com/的错误。