...
|
...
|
@@ -7,13 +7,10 @@ |
|
|
*/
|
|
|
|
|
|
#import "MasterViewController.h"
|
|
|
#import <SDWebImage/UIImageView+WebCache.h>
|
|
|
#import "DetailViewController.h"
|
|
|
#import <SDWebImage/FLAnimatedImageView.h>
|
|
|
#import <SDWebImage/FLAnimatedImageView+WebCache.h>
|
|
|
#import <SDWebImage/UIView+WebCache.h>
|
|
|
|
|
|
|
|
|
@interface MyCustomTableViewCell : UITableViewCell
|
|
|
|
|
|
@property (nonatomic, strong) UILabel *customTextLabel;
|
...
|
...
|
@@ -21,7 +18,6 @@ |
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
@implementation MyCustomTableViewCell
|
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
...
|
...
|
@@ -39,17 +35,14 @@ |
|
|
|
|
|
@end
|
|
|
|
|
|
@interface MasterViewController ()
|
|
|
|
|
|
@property (nonatomic, strong) NSMutableArray<NSString *> *objects;
|
|
|
|
|
|
@interface MasterViewController () {
|
|
|
NSMutableArray *_objects;
|
|
|
}
|
|
|
@end
|
|
|
|
|
|
@implementation MasterViewController
|
|
|
|
|
|
@synthesize detailViewController = _detailViewController;
|
|
|
|
|
|
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
|
|
{
|
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
...
|
...
|
@@ -66,7 +59,7 @@ |
|
|
[SDWebImageManager sharedManager].imageDownloader.username = @"httpwatch";
|
|
|
[SDWebImageManager sharedManager].imageDownloader.password = @"httpwatch01";
|
|
|
|
|
|
_objects = [NSMutableArray arrayWithObjects:
|
|
|
self.objects = [NSMutableArray arrayWithObjects:
|
|
|
@"http://www.httpwatch.com/httpgallery/authentication/authenticatedimage/default.aspx?0.35786508303135633", // requires HTTP auth, used to demo the NTLM auth
|
|
|
@"http://assets.sbnation.com/assets/2512203/dogflops.gif",
|
|
|
@"https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif",
|
...
|
...
|
@@ -80,7 +73,7 @@ |
|
|
nil];
|
|
|
|
|
|
for (int i=0; i<100; i++) {
|
|
|
[_objects addObject:[NSString stringWithFormat:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage%03d.jpg", i]];
|
|
|
[self.objects addObject:[NSString stringWithFormat:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage%03d.jpg", i]];
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -109,7 +102,7 @@ |
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
|
{
|
|
|
return _objects.count;
|
|
|
return self.objects.count;
|
|
|
}
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
...
|
...
|
@@ -130,7 +123,7 @@ |
|
|
[cell.customImageView sd_setIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
|
|
|
|
|
cell.customTextLabel.text = [NSString stringWithFormat:@"Image #%ld", (long)indexPath.row];
|
|
|
[cell.customImageView sd_setImageWithURL:[NSURL URLWithString:_objects[indexPath.row]]
|
|
|
[cell.customImageView sd_setImageWithURL:[NSURL URLWithString:self.objects[indexPath.row]]
|
|
|
placeholderImage:placeholderImage
|
|
|
options:indexPath.row == 0 ? SDWebImageRefreshCached : 0];
|
|
|
return cell;
|
...
|
...
|
@@ -138,13 +131,11 @@ |
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
{
|
|
|
if (!self.detailViewController)
|
|
|
{
|
|
|
self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
|
|
|
}
|
|
|
NSString *largeImageURL = [_objects[indexPath.row] stringByReplacingOccurrencesOfString:@"small" withString:@"source"];
|
|
|
self.detailViewController.imageURL = [NSURL URLWithString:largeImageURL];
|
|
|
[self.navigationController pushViewController:self.detailViewController animated:YES];
|
|
|
NSString *largeImageURLString = [self.objects[indexPath.row] stringByReplacingOccurrencesOfString:@"small" withString:@"source"];
|
|
|
NSURL *largeImageURL = [NSURL URLWithString:largeImageURLString];
|
|
|
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
|
|
|
detailViewController.imageURL = largeImageURL;
|
|
|
[self.navigationController pushViewController:detailViewController animated:YES];
|
|
|
}
|
|
|
|
|
|
@end |
...
|
...
|
|