66 lines
2.0 KiB
Objective-C
66 lines
2.0 KiB
Objective-C
//
|
|
// YYImageExample.m
|
|
// YYKitExample
|
|
//
|
|
// Created by ibireme on 15/7/18.
|
|
// Copyright (c) 2015 ibireme. All rights reserved.
|
|
//
|
|
|
|
#import "YYImageExample.h"
|
|
#import "YYImage.h"
|
|
#import "UIView+YYAdd.h"
|
|
#import <ImageIO/ImageIO.h>
|
|
#import <WebP/demux.h>
|
|
|
|
@interface YYImageExample()
|
|
@property (nonatomic, strong) NSMutableArray *titles;
|
|
@property (nonatomic, strong) NSMutableArray *classNames;
|
|
@end
|
|
|
|
@implementation YYImageExample
|
|
|
|
- (void)viewDidLoad {
|
|
self.title = @"YYImage Demo";
|
|
[super viewDidLoad];
|
|
self.titles = @[].mutableCopy;
|
|
self.classNames = @[].mutableCopy;
|
|
[self addCell:@"Animated Image" class:@"YYImageDisplayExample"];
|
|
[self addCell:@"Progressive Image" class:@"YYImageProgressiveExample"];
|
|
//[self addCell:@"Web Image" class:@"YYWebImageExample"];
|
|
//[self addCell:@"Benchmark" class:@"YYImageBenchmark"];
|
|
[self.tableView reloadData];
|
|
}
|
|
|
|
- (void)addCell:(NSString *)title class:(NSString *)className {
|
|
[self.titles addObject:title];
|
|
[self.classNames addObject:className];
|
|
}
|
|
|
|
#pragma mark - Table view data source
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
return _titles.count;
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YY"];
|
|
if (!cell) {
|
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YY"];
|
|
}
|
|
cell.textLabel.text = _titles[indexPath.row];
|
|
return cell;
|
|
}
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
NSString *className = self.classNames[indexPath.row];
|
|
Class class = NSClassFromString(className);
|
|
if (class) {
|
|
UIViewController *ctrl = class.new;
|
|
ctrl.title = _titles[indexPath.row];
|
|
[self.navigationController pushViewController:ctrl animated:YES];
|
|
}
|
|
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
}
|
|
|
|
@end
|