MultiProductViewer 0.0.2

MultiProductViewer 0.0.2

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2014年12月

Jack Nutting 维护。



MultiProductViewer 实现了一个 GUI,用于在滚动列表中显示多个 App Store 产品。通过点击产品,用户将被带到可以查看应用更多信息并进行购买的页面,使用 SKStoreProductViewController。

背景

此功能最初(在 iOS 5 和 iOS 6)由 SKStoreProductViewController 本身实现。只需传递您的公司标识符,它就会以列表形式呈现您的公司所有产品,并允许用户深入获取更多信息并购买应用程序。从 iOS 7 开始,该功能不再受支持,因此我们编写了这个类来恢复它。

它做什么

我们不仅模仿了旧的行为,还通过显示更大的图标,并允许用户为每个应用程序包含一小段文本来改进它。这样,您可以在列表视图中提供更多信息。此外,我们可以让您选择您想显示的确切应用程序,并将它们分组。

在苹果公司过去做事的方式中,您只需提供公司标识符,苹果公司就会完成其余的工作。由于使用公开 API 从客户端这方面来说并不是真正可行的,因此我们要求您提供您想显示的应用程序列表,并为每个应用程序提供四项数据:名称、苹果标识符、图标 URL 和附加描述性内容的文本字符串。配置可以很容易地使用 JSON 或字典指定。

外观

screenshot

使用方法

创建一个具有以下结构的 JSON 文件

{ "productSpecs" : [
        {
            "title" : "Awesome Games",
            "products" : [
                    {
                          "name" : "FlippyBit",
                          "details" : "Party like it's 1979! Flippy Bit takes the great action of early 2014, and makes it look like it's on an old Atari.",
                          "identifier" : "825459863",
                          "imageURLString" : "http://rebisoft.com/appicons/flippybit512.png"
                    },
                    {
                          "name" : "Scribattle",
                          "details" : "Put your finger-flicking abilities to the test in this all-but-forgotten 2009 App Store hit game!",
                          "identifier" : "301618970",
                          "imageURLString" : "http://rebisoft.com/appicons/scribattle100.png"
                    },
                    {
                          "name" : "Diabolotros",
                          "details" : "Imagine Space Invaders designed for people with keen eyesight and excellent balance.",
                          "identifier" : "315350668",
                          "imageURLString" : "http://rebisoft.com/appicons/diabolotros512.png"
                    },
            ]
        },
        {
            "title" : "Free Games",
            "products" : [
                    {
                          "name" : "Scribattle Lite",
                          "details" : "The free cousin of Scribattle. Try before you buy! And then, buy!",
                          "identifier" : "306058202",
                          "imageURLString" : "http://rebisoft.com/appicons/scribattle100.png"
                    },
                    {
                          "name" : "Diabolotros Lite",
                          "details" : "This free version of Diabolotros lets you come to grips with the Supergun and, perhaps, THE BOMB.",
                          "identifier" : "315938586",
                          "imageURLString" : "http://rebisoft.com/appicons/diabolotros512.png"
                    },
            ]
        },
    ]
}

然后,在您的应用程序中导入几个类

#import "TBTMultiProductViewController.h"
#import "TBTProductCluster.h"

当您想显示视图时,可以这样做

    NSURL *url = [[NSBundle mainBundle] URLForResource:@"example" withExtension:@"json"];
    NSError *error;
    NSData *jsonData = [NSData dataWithContentsOfURL:url];
    if (jsonData) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        if (dict) {
            NSArray *specs = dict[@"productSpecs"];
            NSArray *productClusters = [TBTProductCluster productClustersFromSpecs:specs];
            [TBTMultiProductViewController runWithTitle:@"Other Apps"
                                        productClusters:productClusters
                                               delegate:self];
        }
    }

您还可以实现一个可选的委托方法。这会告诉您没有更多活动发生。传入此方法的视图控制器已经消失。

- (void)multiProductViewControllerDidFinish:(TBTMultiProductViewController *)viewController {
    NSLog(@"RBSMultiProductViewController finished");
}

有关完整使用说明,请参阅包含的示例应用程序。

安装

如果您使用 Cocoapods,只需将以下行添加到 Podfile 中:

pod 'MultiProductViewer'