1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // 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 = @"YYWebImage 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
|