diff --git a/_docs/installation.md b/_docs/installation.md index a6664beb..56943101 100644 --- a/_docs/installation.md +++ b/_docs/installation.md @@ -2,31 +2,57 @@ title: Installation layout: docs permalink: /docs/installation.html -next: references.html +next: intelligent-preloading.html --- -###CocoaPods + +### CocoaPods + AsyncDisplayKit is available on CocoaPods. Add the following to your Podfile: - ```objective-c -pod 'AsyncDisplayKit' -``` +
+pod 'AsyncDisplayKit'
+
+
github "facebook/AsyncDisplayKit"
-```
+
+
+#import <AsyncDisplayKit/AsyncDisplayKit.h>
+
+imageIdentifiers. This list should be in descending order of image quality and will be used by the node to determine what URL to call for each image it will try to load.
-```
+
- (instancetype)initWithURLs:(NSDictionary *)urls
{
- _imageUrls = urls; // something like @{@"thumb": "/smallImageUrl", @"medium": ...}
+ ...
+ _imageURLs = urls; // something like @{@"thumb": "/smallImageUrl", @"medium": ...}
_multiplexImageNode = [[ASMultiplexImageNode alloc] initWithCache:nil
- downloader:[ASBasicImageDownloader sharedImageDownloader]];
+ downloader:[ASBasicImageDownloader sharedImageDownloader]];
_multiplexImageNode.downloadsIntermediateImages = YES;
_multiplexImageNode.imageIdentifiers = @[ @"original", @"medium", @"thumb" ];
_multiplexImageNode.dataSource = self;
- _multiplexImageNode.delegate = self;
- …
+ _multiplexImageNode.delegate = self;
+ ...
}
-```
+
+
+
+
#pragma mark Multiplex Image Node Datasource
- (NSURL *)multiplexImageNode:(ASMultiplexImageNode *)imageNode
URLForImageIdentifier:(id)imageIdentifier
{
- return _imageUrls[imageIdentifier];
+ return _imageURLs[imageIdentifier];
}
-```
+
-Then, in the case that you want to react to the fact that a new image arrived, you can use the following delegate callback.
+
+
#pragma mark Multiplex Image Node Delegate
- (void)multiplexImageNode:(ASMultiplexImageNode *)imageNode
@@ -50,6 +91,19 @@ Then, in the case that you want to react to the fact that a new image arrived, y
fromImage:(UIImage *)previousImage
withIdentifier:(id)previousImageIdentifier;
{
- // this is optional, in case you want to react to the fact that a new image came in
+ // this is optional, in case you want to react to the fact that a new image came in
}
-```
\ No newline at end of file
+
+
+
+
+ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] init];
+imageNode.URL = [NSURL URLWithString:@"https://someurl.com/image_uri"];
+
+
+
+
+- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constraint
+{
+ imageNode.preferredFrameSize = CGSizeMake(100, 200);
+ ...
+ return finalLayoutSpec;
+}
+
+
+
+
+- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constraint
+{
+ CGFloat ratio = 3.0/1.0;
+ ASRatioLayoutSpec *imageRatioSpec = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:ratio child:self.imageNode];
+ ...
+ return finalLayoutSpec;
+}
+
+
+
+